每次执行都报错,提示的错误位置还不一定 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()); ... } }
Connection 和statement要在for循环之前创建,
如: Connection conn=getConnection();
stmt = conn.createStatement();
for(.......){.................}