简体   繁体   中英

executing an update to an sqlite database through jdbc sometimes don't work

I have a Java application connected to a sqlite database through jdbc. Sometimes executing an update don't work. The SQL syntax is right, no exception is thrown and the return value of executeUpdate is 1. The statement is closed after the execution.

I have found a workaround to this situation closing the connection to the database after executing the query, but I don't like this approach.

What could be the problem?

Are you using multiple threads to access the database? SQLite is single threaded (sort of see http://www.sqlite.org/cvstrac/wiki?p=MultiThreading ). As mentioned there, "Do not use the same database connection at the same time in more than one thread".

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