简体   繁体   English

通过jdbc对sqlite数据库执行更新有时不起作用

[英]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. 我有一个通过jdbc连接到sqlite数据库的Java应用程序。 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. SQL语法正确,不会引发异常,executeUpdate的返回值为1。执行后将关闭该语句。

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 ). SQLite是单线程的(请参阅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". 如此处所述,“请勿在多个线程中同时使用同一数据库连接”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM