MyBatis批量入库
public boolean doBatchTblStatDailySiteCustomvarDAO(
List<TblStatDailySiteCustomvar> all) throws Exception {SqlMapSession jdbc = SqlMapSessionFactoryAdStats.getSession();
int number = all.size();
for(int i=0 ;i<number ;i++){
if (i % 10000 == 0) {
jdbc.startBatch();
}
jdbc.insert("insertTblStatDailySiteCustomvar", all.get(i));
if ((i+1) % 10000 ==0) {
jdbc.executeBatch();
}
}
jdbc.executeBatch();
jdbc.commitTransaction();
jdbc.endTransaction();
return true;
}
一万入一次库比一起入库要快些