如何在春季JDBC批量更新中设置批量大小以提高性能。以下是我的代码片段。在春季设置批量大小JDBC批量更新
公共无效insertListOfPojos(最终名单myPojoList){
String sql = "INSERT INTO " + "Student " + "(age,name) " + "VALUES "
+ "(?,?)";
try {
jdbcTemplateObject.batchUpdate(sql,
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
Student myPojo = myPojoList.get(i);
ps.setString(2, myPojo.getName());
ps.setInt(1, myPojo.getAge());
}
@Override
public int getBatchSize() {
return myPojoList.size();
}
});
} catch (Exception e) {
System.out.println("Exception");
}} I just read that in hibernate you can provide your batch size in the configuration xml. Like <property name="hibernate.jdbc.batch_size" value="100"/> .
我们有在弹簧JDBC类似的东西。