Statememt
PreparedStatement 都有addBatch方法
Statememt stmt=conn.createStatement();
stmt.addBatch("insert inti .....");
stmt.addBatch("insert inti .....");
stmt.addBatch("insert inti .....");
stmt.executeBatch();
stmt.close();
PreparedStatement ps=conn.prepareStatement("insert Into biao values(?,?)");
ps.setInt(1,61);
ps.setInt(2,61);
ps.addBatch()
ps.setInt(1,61);
ps.setInt(2,61);
ps.addBatch()
ps.executeBatch();
ps.close();
PreparedStatement 都有addBatch方法
Statememt stmt=conn.createStatement();
stmt.addBatch("insert inti .....");
stmt.addBatch("insert inti .....");
stmt.addBatch("insert inti .....");
stmt.executeBatch();
stmt.close();
PreparedStatement ps=conn.prepareStatement("insert Into biao values(?,?)");
ps.setInt(1,61);
ps.setInt(2,61);
ps.addBatch()
ps.setInt(1,61);
ps.setInt(2,61);
ps.addBatch()
ps.executeBatch();
ps.close();
本文提供了使用Statement和PreparedStatement批量执行SQL插入操作的示例代码,展示了如何通过addBatch方法将多条SQL语句添加到批处理中并最终执行。
2万+

被折叠的 条评论
为什么被折叠?



