Java Connection. Rollback() method: transaction rollback
•
Java
Grammar 1
rollback()
Example
Connection conn = …… //省略部分代码 conn.setAutoCommit(false); //先将事务设为手动提交 Statement st = conn.createStatement(); String sql = "DELETE FROM users WHERE username='xiaoli'"; st.execute(sql); conn.roolback(); //将事务回滚
Grammar 2
rollback(Savepoint savepoint)
Example
Connection conn = …… //省略部分代码 conn.setAutoCommit(false); //先将事务设为手动提交 Statement st = conn.createStatement(); String sql = "DELETE FROM users WHERE username='xiaoli'"; st.execute(sql); conn.roolback(spName); //将事务回滚到保存点
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码