Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Contributor
rduartes
Posts: 7
Registered: ‎03-24-2011
My Device: Playbook

Getting weird error #3122 when accessing a SQLite database on release-build

Hi,

 

I'm getting a very strange error that only happens when I try to run the release build of my application on the simulator. When I run the debug version everything is fine. I can access, read and write the database without a problem. But when I try to run a release build, I keep getting error 3122 (Attempt to write a readonly database.) whenever I try to acess the database.

 

Can anyone help me?

 

Thanks,

Rui

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Getting weird error #3122 when accessing a SQLite database on release-build

What directory is the database in?  app or app-storage?

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Getting weird error #3122 when accessing a SQLite database on release-build

You can't write to any of the files or folders installed with your application.  If you have a database (or any other file) which you need to change after installation, you have to copy it from the app: folder (File.applicationDirectory) to the app-storage: folder (File.applicationStorageDirectory), generally the first time your app launches.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
rduartes
Posts: 7
Registered: ‎03-24-2011
My Device: Playbook

Re: Getting weird error #3122 when accessing a SQLite database on release-build

Hi,

 

I tried with the userDirectory, the documents directory and the appStorage directory. None of them work with the release build. And after I tried to run a release build, the debug build also fails until I change the name of the file to be created.

 

When I change the file name the debug version starts working again. But even with a different file name the release build still fails to run.

 

Thanks,

Rui

New Contributor
rduartes
Posts: 7
Registered: ‎03-24-2011
My Device: Playbook

Re: Getting weird error #3122 when accessing a SQLite database on release-build

Hi Peter,

 

The database is created when the application is run and as I've said in another reply I've tried with most of the file locations that are available and should be writable.

 

Thanks,

Rui

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Getting weird error #3122 when accessing a SQLite database on release-build

It's possible there's a bug involving where those directories point on a release build versus a debug build, though I think that's unlikely.

 

Can you post a snippet showing the code where you determine the location of the database, and initially open it?  And possibly the line which is raising the 3122 error?

 

Alternatively, reduce the problem to the smallest-possible example which demonstrates the problem, so others can try running it to reproduce the error.

 

Or, at least add in a trace() call and write out the .nativePath component of the database's File object just as you create it.

 

By the way, by "created when the application is run" do you mean created from scratch, by doing a SQLConnection.open() on it and then issuing CREATE TABLE statements etc?  Can you confirm that no database file exists in that location prior to the open() call?  (You may want to uninstall the app fully before installing, to test this, rather than just installing over whatever version was there before.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook

Re: Getting weird error #3122 when accessing a SQLite database on release-build

I am also facing the same problem after signed the bar file, Before signed the bar its working fine after signing the bar I am unable to modify the database but can view the data, even I installed the new signing keys the problem is not solved.Please kindly help me. I am waiting for your reply.

New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook

Re: Getting weird error #3122 when accessing a SQLite database on release-build

I got the problem, for new signing keys the application id is changing in the bar file, so the db file is read only for the new version of the app. Is it correct? If yes how to update the applications? I alrady facing this problem please any one help me...

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Getting weird error #3122 when accessing a SQLite database on release-build

Old thread.  Started to get this when upgraded to 3.1 of the SDK.

 

SQLError: 'Error #3122: Attempt to write a readonly database.', details:'attempt to write a readonly database', operation:'execute', detailID:'2206'
	at flash.data::SQLStatement/internalExecute()
	at flash.data::SQLStatement/execute()