Hibernate利用JDBC批操作
阿新 • • 發佈:2017-08-12
pre int execute manager stub == i++ ger pst
@org.junit.Test 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批操作