日期:2014-05-17 浏览次数:20964 次
protected void executeBatchUpdate(List<String> sqList,List<Object[]> parasList){
try {
for(int i=0;i<sqList.size();i++){
prstmt = conn.prepareStatement(sqList.get(i));
if(parasList != null){
int length = parasList.get(i).length > 0? parasList.get(i).length:0;
for(int j=0;j<length;++j){
prstmt.setObject(j+1, parasList.get(i)[j]);
}
}
prstmt.addBatch();
}
prstmt.executeBatch();
conn.commit();
} catch (Exception e) {
e.printStackTrace();
try {
conn.rollback();
} catch (Exception ex) {
ex.printStackTrace();
}
}finally{
closePrstmt();
}
}