当前位置:Gxlcms > 数据库问题 > Hibernate利用JDBC批操作

Hibernate利用JDBC批操作

时间:2021-07-01 10:21:17 帮助过:17人阅读

public void testBatch() { session.doWork(new Work() { @Override public void execute(Connection connection) throws SQLException { // TODO Auto-generated method stub String sql = "insert into manager (MGR_NAME) values (?)"; PreparedStatement pStatement = (PreparedStatement) connection.prepareStatement(sql); for(int i=0;i<10000;i++) { pStatement.setString(1,"xiaoyan"+i); pStatement.addBatch(); if(i%1000==0) { pStatement.executeBatch(); } } pStatement.executeBatch(); pStatement.close(); } }); }

 

Hibernate利用JDBC批操作

标签:ddb   利用   dba   manager   hiberna   throw   set   for   insert   

人气教程排行