Sqlite locking problem
I'm getting a locking error on a query. Looks like an update is locking that table.
[ERROR] Error occurred calling next on a PLSqliteResultSet. SQLite error: 'database table is locked' for 'UPDATE …[rest of update statement]'
The update statement is running as background process using setInterval. I tried to unblock the reading with db.execute('PRAGMA read_uncommitted=true') but that didn't work.
Anyone got any ideas?
5 Answers
-
Accepted Answer
Found it! I had an SQL function where I forgot to call close() after the execute(…). Once I closed it, the error went away. Hopefully that's all it is (was?) for you as well.
-
Same issue occured…
one more tip is to close SQLite browser when u launch application
-
The database file will lock when a write action is being performed such as a insert, delete or update. You'll need to ensure that you close and/or end the transaction of any insert/delete/update queries to prevent a locking run-time error. It's also worth noting that currently a try-catch around the query execution will not catch any SQL error notice.
Docs: "while the database supports concurrent read access, only one user may write to it at a time. This is because a filesystem lock is placed on the file during write operations. This is an important point to bear in mind with multi-threaded applications" – http://wiki.appcelerator.org/display/guides/Working+with+Local+Data
-
I have a similar problem - an Update statement running in the background with setInterval, which results in a 'database table is locked' error. If anyone has a guess, it'd be appreciated.
-
database may be locked due to running the titanium project again and again.This occurs
while copying resources.Since the resources are huge ,it takes time to run on the
emulater or device.so better keep the images or other resources in sdcard.