Robin De Baets
Robin De Baets

Reputation: 399

Java SQLite in WAL mode: the database is locked

I'm using SQLite in my multithreaded application. To make sure that that won't cause problems, I've set the SQLite database to WAL mode. All threads share one connection that is never closed during runtime. I'm however, getting this error when executing a batch and I have no idea why it happens. All writes to the database are done using a singlethreadexecutor, reads are done in multiple threads.

java.sql.SQLException: database is locked 
at org.sqlite.DB.throwex(DB.java:370) 
at org.sqlite.DB.executeBatch(DB.java:302) 
at org.sqlite.PrepStmt.executeBatch(PrepStmt.java:93) 

Thanks in advance

Upvotes: 1

Views: 927

Answers (1)

Robin De Baets
Robin De Baets

Reputation: 399

Found the answer: I wasn't properly shutting my connection after server reloads due to remains of an old pooling system.

Upvotes: 2

Related Questions