1 //事务管理 2 public void executeTran(String[] sql){睿共享 3 Connection connection = getConnection(); 4 Prepar睿共享 edStatement pstmt = null; 5 6 try { 7 //开启自动提交 8 connection.setAutoCommit(false); 9 //预编译sql 10 for (int i = 0;睿共享 i) { 11 pstmt 睿共享 = connection.prepareStatemen睿共享 t(sql[i]); 12 pstmt.executeUpdate(); 13 } 14 } catch (SQLException e) { 15 e.printStackTrace(); 16 } 17 }