Statement st = null;
try{
conn.setAutoCommit(false);
st = conn.createStatement();
for(int i=0;i<sqlBatch.length;i++){
st.addBatch(sqlBatch[i]);
//commit per 500 sql sentences
if(i!=0&&i%500==0){
st.executeBatch();
st.clearBatch();
conn.commit();
System.out.println("Update Success!"+i);
}
}
st.executeBatch();
st.clearBatch();
conn.commit();
}catch(SQLException se){
System.out.println("SQLException"+se.getMessage());
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}