Disable oracle autocommit on close connection

依然范特西╮ 提交于 2021-02-10 08:42:11

问题


I have a question about Oracle autocommit on close connection event.

Information from oracle docs(http://docs.oracle.com/cd/E16655_01/java.121/e17657.pdf):

If the auto-commit mode is disabled and you close the connection without explicitly committing or rolling back your last changes, then an implicit COMMIT operation is run.

So, I want to disable this feature programmatically in JDBC driver. I don't wan't do autocommit on connection close at least one transaction. Is it possible?

P.S. setAutoCommit change JDBC action. "Auto_Commit" start new transaction and call commit on every statement. It is not solution for my problem.


回答1:


EDIT. Possible duplicate : Does Java Connection.close rollback?

According to the javadoc, you should try to either commit or roll back before calling the close method. The results otherwise are implementation-defined.




回答2:


You can have a look at the setAutoCommit() method of the Connection class. More details here



来源:https://stackoverflow.com/questions/23263139/disable-oracle-autocommit-on-close-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!