conn = getConnection();
conn.setAutoCommit(false);
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement("INSERT INTO user(id,name) VALUES(?, ?)");
for (int i = 0; i < 10000; i++) {
ps.setInt(1,i);
ps.setString(2,"name_"+String.valueOf(i));
ps.addBatch();
//ps.clearParameters(); 这句话报空指针异常,不知为什么
}
ps.executeBatch();
conn.commit();