[SQLiteJDBC] Question on sqlite jdbc wrapper

ramakrishna menon rmenon.us at gmail.com
Sun Jul 11 14:20:29 EDT 2010


Hi folks
I am new to the sqlite world. I decided to use sqlite for a light
weight file based queue. I decided to use the sqlitejdbc mainly
because I wanted a clean wrapper over original sqlite implementation.
My requirement is that the database access can be restricted to only
one thread at a time (reader or writer). I do have multiple threads
but I use a sempahore at the point of getting a connection and closing
a connection to ensure that only one thread can access the file.

My program fails consistently at the same point. This is the thread
that selects "unprocessed" entries from the queue table, processes
them (a non sqlite operation) and then marks the rows as processed. It
always fails at the point of commit that happens right after the
update statement that runs to mark the rows as "processed". The error
is always

java.sql.SQLException: database is locked
	at org.sqlite.DB.throwex(DB.java:288)
	at org.sqlite.DB.exec(DB.java:68)
	at org.sqlite.Conn.commit(Conn.java:172)

Can this happen even if I guarantee that only one thread is accessing
db file at a time? I also ensure that I am not accessing it from
outside the program (eg using sqlite3.exe)

I am running my tests in Windows though the final deployment would be
on Linux (mentioning it in case this is a windows only issue, then it
is ok.)

Any help on this would be appreciated.

Menon



More information about the SQLiteJDBC mailing list