java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

每次执行都报错,提示的错误位置还不一定
for(...){
...
Connection conn = null;

Statement stmt = null;

...
stmt = conn.createStatement();

int n=stmt.executeUpdate("update 表1 set ... where ...");
stmt.executeUpdate("delete from 表2 where...");
stmt.executeUpdate("update 表2,表3 set ... where  ...");
stmt.executeUpdate("update 表2 set ... where ...");
while(){
....
rs = stmt.executeQuery(sql.toString());
...
rs = stmt.executeQuery(sql.toString());
...
}
}
眼眸繁星
浏览 1069回答 1
1回答

动漫人物

Connection 和statement要在for循环之前创建, 如: Connection conn=getConnection();          stmt =  conn.createStatement();    for(.......){.................}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java