The sqlite3_get_autocommit() interface returns non-zero or zero if the given database connection is or is not in autocommit mode, respectively. Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
因此,可以通过BEGIN TRANSACTION语句禁用自动提交。没有为此提供单独的API函数
# 3 楼答案
Jefromi和king_nak是正确的-您只需要发出SQL语句来开始和结束事务
SQLiteConnection con = new SQLiteConnection();
con.exec("BEGIN");
// do transaction work - auto-commit is disabled
con.exec("COMMIT");
// auto-commit is enabled again
# 1 楼答案
编辑:我混淆了sqlite4java和sqliteJDBC包。所以下面的代码没有帮助。尽管如此,我还是保留它作为参考
获得连接后,只需调用
setAutoCommit(false)
# 2 楼答案
关于SQLite's C interface description:
因此,可以通过
BEGIN TRANSACTION
语句禁用自动提交。没有为此提供单独的API函数# 3 楼答案
Jefromi和king_nak是正确的-您只需要发出SQL语句来开始和结束事务