请教有关事务提交的问题,先谢了。 stmt.close();should be in a try/catch block 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该这样写:Connection conF = con.getConnection(); Statement stmt = null; try{ conF.setAutoCommit(false); stmt = conF.createStatement(); stmt.executeUpdate(strSql_0); stmt.executeUpdate(strSql_1); stmt.executeUpdate(strSql_2); stmt.executeUpdate(strSql_3); conF.commit(); conF.setAutoCommit(true); //add by roger2008 }catch(Exception e){ conF.rollback(); out.println("删除异常!"); }finally{ try { if(stmt!=null) stmt.close(); if(conF!=null) //modified by roger2008 conF.close(); con.close(); // ????????? } catch(Exception e){ } }先关stmt,后关conF,不明白con是什么类,是缓冲池吗?为什么要con.close()? javaSE:判断一个文本框的内容是否为空? swing 中能输出文件下标吗? 两个数组相乘 一道算法题 JAVA中可不可获得当前电脑的网络带宽阿? 请问组建和中间件有什么区别吗? 第二个java问题求解,望大虾指教 java.util.Properties 类中store(OutputStream out, String header) 的方法如何用? 头痛的要死的问题! java打印对话框 菜鸟问题 关于JDBC的PreparedStatement类。。。。。
Statement stmt = null;
try{
conF.setAutoCommit(false);
stmt = conF.createStatement(); stmt.executeUpdate(strSql_0);
stmt.executeUpdate(strSql_1);
stmt.executeUpdate(strSql_2);
stmt.executeUpdate(strSql_3);
conF.commit();
conF.setAutoCommit(true); //add by roger2008
}catch(Exception e){
conF.rollback();
out.println("删除异常!");
}finally{
try {
if(stmt!=null)
stmt.close();
if(conF!=null) //modified by roger2008
conF.close();
con.close(); // ?????????
} catch(Exception e){
} }先关stmt,后关conF,不明白con是什么类,是缓冲池吗?为什么要con.close()?