62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) throws ClassNotFoundException, SQLException
{
Connection con = DBUtil.getConnection();
con.setAutoCommit(false);
PreparedStatement ps =con.prepareStatement("insert into BigInsert nologging values (?)");
long start = System.currentTimeMillis();
for(int i=1;i<1000001;i++)
{
ps.setInt(1, i);
//ps.executeUpdate();
ps.addBatch();
if(i%10000==0)
{
ps.executeBatch();
ps.clearBatch();
}
}
con.commit();
long end = System.currentTimeMillis();
System.out.println(end-start);
ps.close();
con.close();
}