22,210
社区成员
发帖
与我相关
我的任务
分享
@Test
public void fun() throws Exception{
Connection con = JDBCUtil.getConnection();
String sql = "INSERT INTO account VALUES(?,?)";//数据库表结构为 username varchar(50),password varchar(50)
PreparedStatement ps = con.prepareStatement(sql);
for (int i = 0; i < 100; i++) {
ps.setString(1, "张三"+i);
ps.setString(2, "123"+i);
ps.addBatch();
}
long s = System.currentTimeMillis();
ps.executeBatch();
ps.clearBatch();
long e = System.currentTimeMillis();
System.out.println(e-s);//执行一百次后大约为2341
}