81,092
社区成员
发帖
与我相关
我的任务
分享
...
conn.prepareStatement(sql1);
conn.prepareStatement(sql2);
pstmt.execute();
Connection con=null;
Statement st =null;
try {
con = DriverManager.getConnection("","","");
con.setAutoCommit(false);
st=con.createStatement();
st.addBatch("sql1");
st.addBatch("sql2");
st.addBatch("....");
st.addBatch("sqln");
st.executeBatch();
con.commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(st!=null){
try {
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(con!=null){
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
……
conn.prepareStatement(sql1);
pstmt.execute();
conn.prepareStatement(sql2);
pstmt.execute();