当前位置:Gxlcms > 数据库问题 > JDBC值事务

JDBC值事务

时间:2021-07-01 10:21:17 帮助过:2人阅读

String transaction(AccountInfo from, AccountInfo to, int account) { boolean res = false; Connection con = DBUtil.getConnection(); try { con.setAutoCommit(false);//关闭默认的事务 from.setAccount(from.getAccount() - account); res = update(from); // String str = null; // str.split("2"); to.setAccount(to.getAccount() + account); res = update(to); con.commit(); //提交 return "success"; } catch (Exception e) { try { con.rollback();// 回滚 } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return "failed"; } }

 

JDBC值事务

标签:

人气教程排行