当前位置: 代码迷 >> J2EE >> 为何不会rollback.解决思路
  详细解决方案

为何不会rollback.解决思路

热度:34   发布时间:2016-04-22 02:59:28.0
为何不会rollback...?
代码如下。每次都会更新值,ROLLBACK没用么?
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement("update test set name=? where id=?");
pstmt.setString(1, "GG");
pstmt.setInt(2, 3);
pstmt.executeUpdate();
conn.rollback();

------解决方案--------------------
探讨
引用:

光看代码好像没有问题啊,
再从其他方面找找原因吧!

我纯写JDBC 也不行。。
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/jpetstore";
Connection conn = DriverManager.g……