import java.sql.*; public class Bdate{ String url = "jdbc:sqlite:d:/farcry/userDate.db"; Connection con; ResultSet res; public void bd(String sql) throws SQLException { con = DriverManager.getConnection(url); con.createStatement().execute(sql); } public void bs(String sql)throws SQLException{ con = DriverManager.getConnection(url); res=con.createStatement().executeQuery(sql); } } The problem is the following: I need two methods: one request to the database without returning Resultset, the second with returning. Both methods are constantly used and several apparently connection is created, as an example I call the 1st method, the 2nd, then the 1st and the base drops
org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (database is locked) at org.sqlite.core.DB.newSQLException (DB.java:941) at org.sqlite.core.DB.newSQLException (DB.java : 953) at org.sqlite.core.DB.execute (DB.java:854) at org.sqlite.core.CoreStatement.exec (CoreStatement.java:80) at org.sqlite.jdbc3.JDBC3Statement.execute (JDBC3Statement. java: 53) at Bdate.bd (Bdate.java:14) at BotStart.onUpdateReceived (BotStart.java:34) at java.base / java.util.ArrayList.forEach (ArrayList.java:1540) at org.telegram. telegrambots.meta.generics.LongPollingBot.onUpdatesReceived (LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession $ HandlerThread.run (DefaultBotSession.java:305)
if you set con.close in the 1 method after 4-5 calls the base drops again
org.sqlite.SQLiteException: [SQLITE_BUSY] The database file is locked (database is locked) at org.sqlite.core.DB.newSQLException (DB.java:941) at org.sqlite.core.DB.newSQLException (DB.java : 953) at org.sqlite.core.DB.execute (DB.java:854) at org.sqlite.core.CoreStatement.exec (CoreStatement.java:80) at org.sqlite.jdbc3.JDBC3Statement.execute (JDBC3Statement. java: 53) at Bdate.bd (Bdate.java:14) at BotStart.onUpdateReceived (BotStart.java:34) at java.base / java.util.ArrayList.forEach (ArrayList.java:1540) at org.telegram. telegrambots.meta.generics.LongPollingBot.onUpdatesReceived (LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession $ HandlerThread.run (DefaultBotSession.java:305)
if we set con.close in method 2, we get an error immediately after calling 2 method
java.sql.SQLException: The database has been closed at org.sqlite.core.NativeDB.throwex (NativeDB.java:478) at org.sqlite.core.NativeDB.column_text_utf8 (Native Method) at org.sqlite.core.NativeDB .column_text (NativeDB.java:249) at org.sqlite.jdbc3.JDBC3ResultSet.getString (JDBC3ResultSet.java:444) at BotStart.onUpdateReceived (BotStart.java:66) at java.base / java.util.rata.dAdude.ApdateReceived (BotStart.java:66) at java.base / java.util.rtaredd (BotStart.java:66) ArrayList.java:1540) at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived (LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession $ HandlerThread.run-a challenge, an account that is defined by an account defaults.updatesreceivers.DefaultBotSession $ DisclerThread.run.
How to be I do not know, Google solutions do not work
ConnectionandResultSetand close the connection there. But a lot of connections can lead to problems if you have multithreading - ChubatiyResultSet"up" and then parse it to the list of objects and give the list (and closers) - Chubatiy