AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
### DBUtils完成转账 ~~~ Connection connection = null; try { QueryRunner queryRunner = new QueryRunner(); //得使用这种构造函数,因为传入连接池的我们不能保证执行SQL语句的是同一个连接.  connection = C3P0Utils.getConnection(); connection.setAutoCommit(false); int tom = queryRunner.update(connection, "update account set money = money - ? where name = ?", 1000, "tom"); int jack = queryRunner.update(connection, "update account set money = money + ? where name = ?", 1000, "jack"); System.out.println(1 / 0); connection.commit(); if (tom > 0 && jack > 0) { System.out.println("转账成功"); } } catch (SQLException e) { try { connection.rollback(); } catch (SQLException sql) { sql.printStackTrace(); } e.printStackTrace(); } finally { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } ~~~