批量插入数据
//批量插入的方式二:使用preparedstatement
@Test
public void testInsert1() {
Connection conn = null;
PreparedStatement ps = null;
try {
conn = JDBCUtil.getConnection();
String sql="insert into goods(name) values(?)";
ps = conn.prepareStatement(sql);
for (int i=1;i<=20000;i++){
ps.setObject(1,"name_"+i);
ps.execute();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.closeResource(conn, ps);
}
}