Mysql中开启事务 不执行rollback 一样不会更新数据 请问!
高洛峰
高洛峰 2017-04-17 13:14:22
0
2
675

我不执行commit就行了,我还要执行rollback有啥用?

网上查询了下没有什么确切答案,都说要执行rollback才能回滚,可是当我没有执行commit的时候 没有执行rollback 一样回滚了,网上查了很多文字 确没有说不执行rollback和commit一样回滚有啥区别?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
巴扎黑

When an error occurs, there is no need to explicitly call rollback, it will automatically roll back.

But there is a requirement: no error occurs, but we need to judge that after a certain situation is met, we also need to roll back. At this time, we need to explicitly call rollback.

小葫芦

Here:

http://docs.oracle.com/javase...

It is strongly recommended that an application explicitly commits or rolls back an active transaction prior to calling the close method. If the close method is called and there is an active transaction, the results are implementation-defined.

It means that if there are operations in the transaction, the behavior of direct shutdown is determined by the implementation, it may be commit or it may be rollback. The implementation of MySQL is rollback, so there is no problem if you close it directly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template