java 中怎么开启事务
收起
云计算小粉
2018-05-10 20:09:09
4352
0
1
条回答
写回答
取消
提交回答
-
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@host:1521:SID","username","password");
conn.setAutoCommit(false); //取消自动提交
PreparedStatement ps = conn.prepareCall("update something");
ResultSet rs = ps.executeQuery();
conn.commit(); //手动提交
2019-07-17 22:18:14