Sunday, December 16, 2012

An effective solution to "java.sql.SQLException: [SQLITE_BUSY] The database file is locked (database is locked)"

Similar to links like:

The sqlite database is sometimes locked very long when trying to insert, delete or update data with a java program. I had read the posts above but found no definite and clear solution in these  answers. I had also tried the proposed solution shown in the video about "the database is locked problem" in vain.

But finally, I figured out a simple and effective way to circumvent this problem so that I can continue my coding. The solution is as follows:

1.Backup the database folder where the locked sqlite db is located.

 2. Use Unlocker to delete the locked .db file

Unlocker can be downloaded from
in the webpage

3.Copy the backup .db file back to the directory of the deleted locked sqlite .db.

These three simple steps can effectively solve the problem of  "java.sql.SQLException: [SQLITE_BUSY]  The database file is locked (database is locked)." Try it to evade this problem if baffled by it for quite a long time.