2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > JDBC06 其他操作及批处理Batch

JDBC06 其他操作及批处理Batch

时间:2022-10-19 19:12:46

相关推荐

JDBC06 其他操作及批处理Batch

灵活指定SQL语句中的变量

-PreparedStatement

对存储过程进行调用

-CallableStatement

运用事务处理

-Transaction

批处理

-Batch

-对于大量的批处理,建议使用statement,因为PreparedStatement的预编译空间有限,当数据量特别大的时候,会发生异常

-事务提交方式设为手动提交

conn.setAutoCommit(false);//设为手动提交stmt=conn.createStatement();long start =System.currentTimeMillis();for(int i=0;i<20000;i++) {stmt.addBatch("insert into t_user (username,pwd,regTime) values ('zhang"+i+"',1234,now())"); }stmt.executeBatch();mit();long end =System.currentTimeMillis();System.out.println("耗时:"+(end-start)+"ms");/***Output:耗时:14422ms**/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。