How to disable autocommit in sqlite4java?

I recently played with sqlite4java library. I think I really understood him. The only thing that bothers me is that I don’t know how to disable auto-commit using this library. Can anybody help? Sample code would be greatly appreciated.

Thanks in advance, Boro

+4
source share
3 answers

Jefromi and king_nak are true - you just need to issue the SQL statements that begin and end with the transaction.

SQLiteConnection con = new SQLiteConnection();
con.exec("BEGIN");
// do transaction work - auto-commit is disabled
con.exec("COMMIT");
// auto-commit is enabled again
+5
source

Change . I confused sqlite4java with sqliteJDBC package. Therefore, the code below will not help. However, I keep it for reference.

After you got the connection, just call setAutoCommit(false)

java.sql.Connection con = DriverManager.getConnection("jdbc:sqlite:/your/db/file", "user", "password");
con.setAutoCommit(false);
+2

SQLite C:

sqlite3_get_autocommit() , , . . Autocommit BEGIN. COMMIT ROLLBACK.

, BEGIN TRANSACTION. API.

+1

All Articles