Bug 60522 - An option for setting if the transaction should be rolled back when a connection is abandoned
Summary: An option for setting if the transaction should be rolled back when a connect...
Status: NEW
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2016-12-27 03:51 UTC by lff0305
Modified: 2016-12-27 03:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description lff0305 2016-12-27 03:51:57 UTC
Currently, if the connection is abandoned, it do nothing to commit() or rollback(). 
However, I have seen problems for this, especially on Oracle, because for Oracle, the Oracle JDBC driver will commit the transaction when close() is called. See http://stackoverflow.com/questions/218350/does-java-connection-close-rollback

So, the following code will causes dirty data in DB:

Connection conn = getConnectionFromPool();
try {
     //Do something with the conn. And after some time, it is ABANDONED.
    conn.commit(); // OOPS!!!! Connection already closed because it is abandoned and closed.
} catch (Exception e) {
     log it;
     conn.rollback();  <===== Rollback failed, because the connection is abandoned and closed.

!!!!!!!! Dirty data got. Because in Oracle, the JDBC driver will commit() the transaction when the connection is closed.