Bug 60522

Summary: An option for setting if the transaction should be rolled back when a connection is abandoned
Product: Tomcat Modules Reporter: lff0305
Component: jdbc-poolAssignee: Tomcat Developers Mailing List <dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

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.