2

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
grinder
  • 436
  • 1
  • 6
  • 10

2 Answers2

0

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.

Community
  • 1
  • 1
Rob van Laarhoven
  • 8,737
  • 2
  • 31
  • 49
  • Plz see again the question. Problem in autocommit on lost connection to db server. By default, Oracle commit transaction on lost connection – grinder Apr 24 '14 at 08:06
  • 1
    I need that DB server rollback this transaction automaticly then connection lost. JDBC driver can't do this because we haven't connection. This is server settings. And I think we can set property for every transaction and change on close connection action. – grinder Apr 24 '14 at 09:22
  • A lost connection to the server a different scenario from a connection.close. A connection.close does a implicit commit as the docs mention. A lost connection is handled by oracle's dead connection detection and does a rollback. – Rob van Laarhoven Apr 24 '14 at 11:00
-1

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

AdityaKeyal
  • 1,208
  • 8
  • 14
  • 1
    Plz see again the question. Problem in autocommit on lost connection to db server. By default, Oracle commit transaction on lost connection. – grinder Apr 24 '14 at 09:29