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();
}