[dbcp] PoolableConnectionFactory.passivateObject() setting autoCommit(true) ?!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[dbcp] PoolableConnectionFactory.passivateObject() setting autoCommit(true) ?!

Stephen Crowley
I've been experiencing very odd behaviour with regard to autocommit and
abandoned connections. It seems that when connections are reclaimed that
autocommit somehow becomes set to true.

public void passivateObject(Object obj) throws Exception {
if(obj instanceof Connection) {
Connection conn = (Connection)obj;
if(!conn.getAutoCommit() && !conn.isReadOnly()) {
conn.rollback();
}
conn.clearWarnings();
conn.setAutoCommit(true);
}
if(obj instanceof DelegatingConnection) {
((DelegatingConnection)obj).passivate();
}
}


How can conn.setAutoCommit(true) possibly be the correct behaviour here? Is
this correct?

Thanks,
Stephen