package cn.itcast.jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Savepoint;
import cn.itcast.utils.JdbcUtils;
public class Demo2 {
/**
* 事务回滚点
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
Connection conn = null;
PreparedStatement st = null;
ResultSet rs = null;
Savepoint sp = null;
try{
conn = JdbcUtils.getConnection();
conn.setAutoCommit(false); //start
String sql1 = "update account set money=money-100 where name='aaa'";
conn.prepareStatement(sql1).executeUpdate();
sp = conn.setSavepoint(); //设置回滚点
String sql2 = "update account set money=money-100 where name='aaa'";
conn.prepareStatement(sql2).executeUpdate();
String sql3 = "update account set money&#
设置事务的回滚点
最新推荐文章于 2024-05-03 02:44:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)