jdbc批量插入

jdbc批量插入,关键代码:

 String  sqlInsert = " insert into USER (id,name,password) values(?,?,?) ";
conn = getConnection(); //得到连接
 conn.setAutoCommit(false);
 pstmt = conn.prepareStatement(sqlInsert);

 while(...){
     pstmt.setXxx(index,value);
     pstmt.addBatch();
}
       pstmt.executeBatch();
       conn.commit();

 

posted @ 2013-09-14 10:42  空虚公子  阅读(312)  评论(0)    收藏  举报