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