EAS BOS 回滚提交数据

来源:互联网 发布:法律知询 编辑:程序博客网 时间:2024/04/27 23:24
 public int delete(int sID) {
 
Connection con = getConnection(ctx);    
  
try {
   con.setAutoCommit(false);// 更改JDBC事务的默认提交方式
   dbc.executeUpdate("delete from xiao where ID=" + sID);
   dbc.executeUpdate("delete from xiao_content where ID=" + sID);
   dbc.executeUpdate("delete from xiao_affix where bylawid=" + sID);
   con.commit();//提交JDBC事务
   con.setAutoCommit(true);// 恢复JDBC事务的默认提交方式
   dbc.close();
   return 1;
  }
  catch (Exception exc) {
   con.rollBack();//回滚JDBC事务
   exc.printStackTrace();
   dbc.close();
   return -1;
  }
原创粉丝点击