언어 설정

Menu
Sites
Language
Problem with open database

 

Hi
I have install a SDK 2.0. I working on Ubuntu 12.10 32bit
 
I would like use a database in my application but I have a problem with open database.
 
I use a sample from documentation:
https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.native.apireference%2FclassTizen_1_1Io_1_1Database.html
 
dbName = App::GetInstance()->GetAppDataPath() + L"sample.db";

pDatabase = new Database();

if (!pDatabase)
{
 goto CATCH;
}

r = pDatabase->Construct(dbName, "a+");
if (IsFailed(r)) // r = E_INVALID_ARG
{
  goto CATCH;
}
Method Construct return E_INVALID_ARG:
 
In log I have:
02-22 02:53:26.761 : ERROR / Tizen::Io ( 2411 : 2411 ) : result Tizen::Io::_DatabaseImpl::Construct(const Tizen::Base::String&, const char*, const Tizen::Base::ByteBuffer*) (410). > [E_INVALID_ARG] Parent Directory dose not exist.
 
02-22 02:53:26.761 : ERROR / Tizen::Io ( 2411 : 2411 ) : result Tizen::Io::Database::Construct(const Tizen::Base::String&, const char*) (112). > [E_INVALID_ARG] Propagated.

What's wrong, he's an example of the documentation ?

Thanks for your help

 

Edited by: Brock Boland on 17 3월, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

8 댓글
dhirendra kumar
Check if folder by name "data" exist in your project. If not, create manually a folder by name "data" under the project root (i.e. Right click on project name -> New -> Folder -> Enter "data" ->click Finish) It should work then
Dobrowolski
I debug my project and at runtime r = pDatabase->Construct(dbName, "a+"); variable dbName have value "data/sample.db". I still have the same problem E_INVALID_ARG
Dobrowolski
When I run project which is converted from bada 1.0 project to tizen native application App::GetInstance()->GetAppDataPath() return "data/" When I started a new tizen project App::GetInstance()->GetAppDataPath() retrun "/opt/apps/pDk5sWZTVu/data/sample.db" and method pDatabase->Construct return E_SUCCESS
Dobrowolski
In "HelloWorld" program GetAppDataPath() return good value In my program which I created as Tizen EmptyProject GetAppDataPath still return "data/" Does anyone have any idea?
Dobrowolski
I started new project wrote one line to bool MyApp::OnAppInitializing(AppRegistry& appRegistry) { Tizen::Base::String appdir = Tizen::App::App::GetInstance()->GetAppDataPath(); ... And return good value "/opt/apps/iJ3voRGg1y/data/" when I copy source code (.cpp and .h) from my old bada project the same line: Tizen::Base::String appdir = Tizen::App::App::GetInstance()->GetAppDataPath(); starts return wrong value: "/data"
wil smith
To avoid this problem ensure you are not using GetAppDataPath() for global initialization. The safest way is, use GetAppDataPath() inside some function.
y Rajyalakshmi
Is it possible to read the data without any insert command in our code. I have my own database can we extract data directly after open the database. String dataPath = App::GetInstance()->GetAppDataPath(); __dbPath.Append(String(dataPath + L"bartendersbible_minerva.db")); __pDatabase = new Database(); if (!__pDatabase) { AppLog("not found"); // goto CATCH; } AppLog("found database"); r = __pDatabase->Construct(__dbPath, "a+"); if (File::IsFileExist(__dbPath)) { AppLog("File exits"); } String sql; sql.Append(L"SELECT PageInstanceId from page_instance "); pEnum = __pDatabase->QueryN(sql); if (pEnum == NULL) return E_FAILURE; if(pEnum) { AppLog("pEnum Success dsdf"); int iVal; while (pEnum->MoveNext() == E_SUCCESS) { r = pEnum->GetIntAt(0, iVal); if (IsFailed(r)) { AppLog("Failed"); } AppLog("pageInstanceId=%d, ", iVal); } delete pEnum; } It is failing at pEnum.. OR do we have to set any previleges to open own database. Regards Rajyalakshmi
wil smith
As long as the database file is SQLite compliant, you can directly access or query it. You can use the SQLite tools available in it's official site.