
如何通过程序实现同一事务中多次数据库更新的错误回滚
1个回答
展开全部
具体情况是:
begin transaction //使用程序来完成对事务的控制。
// connect database
update the first row
// update successfully
update the second row
// fail to update due to connection lost.
这个时候我怎么实现Roll back 第一条更新的数据。
测试代码:
c.setAutoCommit(false);
PreparedStatement s = c.prepareStatement("insert into a values (?)");
Savepoint s1 = c.setSavepoint();
begin transaction //使用程序来完成对事务的控制。
// connect database
update the first row
// update successfully
update the second row
// fail to update due to connection lost.
这个时候我怎么实现Roll back 第一条更新的数据。
测试代码:
c.setAutoCommit(false);
PreparedStatement s = c.prepareStatement("insert into a values (?)");
Savepoint s1 = c.setSavepoint();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询