执行 java 程序时出现以下错误
Exception in main class java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
程序:
String query = "select id from testtable where status=\"" + 1 + "\" limit 10";
PreparedStatement s = conn.prepareStatement(query);
ResultSet res = s.executeQuery();
while (res.next()) {
CId = res.getString(1);
System.out.println("cid:"+CId);
String delquery = "delete from testtable2 where comid=\"" + CId + "\"";
PreparedStatement pre = conn.prepareStatement(delquery);
System.out.println("del:"+pre.executeUpdate());
String delquery2 = "delete from testtable where id=\"" + CId + "\"";
PreparedStatement pre2 = conn.prepareStatement(delquery2);
pre2.executeUpdate();
}