我使用 mysql 4.1.22 android 2.3.3。
如果自动提交为真,则更新/插入的每个操作都会锁定表并抛出异常“超过锁定等待超时”。好吧:禁用自动提交并在执行语句后从您的连接调用 commit()。
示例代码:
connection.setAutoCommit(false)
stmt = connection.CreateStatement();
int ris = stmt.executeUpdate("INSERT INTO tablename () VALUES ()");
connection.commit();
stmt.close();
如有必要,关闭连接或继续另一个语句。我希望这会有所帮助。