首页 新闻 会员 周边

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

0
悬赏园豆:5 [已解决问题] 解决于 2012-11-07 15:35
每次执行都报错,提示的错误位置还不一定
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());
...
}
}
秋风净的主页 秋风净 | 初学一级 | 园豆:175
提问于:2012-10-29 16:26
< >
分享
最佳答案
0

Connection 和statement要在for循环之前创建,

如: Connection conn=getConnection();

         stmt =  conn.createStatement();

   for(.......){.................}

收获园豆:5
miss you | 菜鸟二级 |园豆:209 | 2012-11-07 14:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册