Jdbc批量更新

 1 Connection conn = null;
 2         PreparedStatement stmt =  null;
 3         try{
 4             conn = JdbcUtil.getConnection();
 5             stmt = conn.prepareStatement("insert into t1 (id,name) values(?,?)");
 6             
 7             for(int i=0;i<10;i++){
 8                 stmt.setInt(1, i+1);
 9                 stmt.setString(2, "aa"+(i+1));
10                 stmt.addBatch();//向缓存中加的参数
11             }
12             
13             int [] ii = stmt.executeBatch();//批处理.每条语句影响的行数
14             
15             for(int i:ii)
16                 System.out.println(i);
17         }catch(Exception e){
18             e.printStackTrace();
19         }finally{
20             JdbcUtil.release(null, stmt, conn);
21         }
原文地址:https://www.cnblogs.com/duyunchao-2261/p/7592709.html