简体   繁体   中英

SQLite Exception to handle locked databases

I am working with SQLite database files, and I notice that when database file is in use, I see that it prints "SQLite error: database is locked". I have tried using SQLiteException with try.catch, but that does not work. What I want to know, is, how can I catch the error before it repeats, and display a message to the user? In other words, what I want to do is set the default retries\\timeout for the connection, so that my application does not appear to be unresponsive while it retries.

To resolve this, simply rename the file and copy it back to it's original name and location.

mv mydata.db temp.db
cp temp.db mydata.db

Your question is similar to the query "How do I unlock a SQLite database?" I think the answers provided for this question will help you to resolve your issue very easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM