开发者

java.sql.SQLException: database locked

We are using sqlite056.jar in our code. While inserting into database in batch we are getting exception on line when we going to commit.

Lines of Code

<ob开发者_开发百科ject of Connection>.commit();
<object of Connection>.setAutoCommit(true);

Exception

java.sql.SQLException: database locked


Connection needs to be closed after each query. If any of the connections still persist. I had got the same error on Java desktop apps, now solved.


Reading an SQLite database sets the locking state to Shared. Multiple readers can be active at the same time.

Writing to an SQLite database sets the locking state to Exclusive. No other processes can be active at that time.

You can find a detailed explanation on http://www.sqlite.org/lockingv3.html


It seems that more than one process is trying to modify the database. You can have only one connection open at any given time. More background on the problem may help us provide you with a more concrete answer.


In my case, I forgot to add WHERE clause in my UPDATE query, and that gives "database locked" error.

Carefully check your queries.

Edit: I forgot to indicate that I have used a type of UPDATE query where I'm changing multiple attributes:

UPDATE Users SET weight = 160, desiredWeight = 145 WHERE id = 1;


Close DB Browser (worked for me) or anything else accesses the database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜