Bug 51879

Summary: Improve access to Native Connection Methods
Product: Tomcat Modules Reporter: Mike Youngstrom <youngm>
Component: jdbc-poolAssignee: Tomcat Developers Mailing List <dev>
Status: NEEDINFO ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Mike Youngstrom 2011-09-22 23:23:49 UTC
I'm attempting to use tomcat-jdbc with Oracle Streams AQ.  Oracle Streams AQ requires a connection of type OracleConnection.  Streams AQ will also under some circumstances close the OracleConnection it is using.  If I use unwrap to get an OracleConnection and then Streams AQ closes that connection it will leave my tomcat-jdbc pool in a messed up state since connections will be closed that tomcat-jdbc thinks are open.

I can see 2 ways tomcat-jdbc may be able to help simplify this use case for developers:

1.  Tomcat JDBC can proxy connections it returns from Wrapper.unwrap with the interface provided.  Currently tomcat-jdbc's ProxyConnection class will only unwrap to PooledConnection or XAConnection.  Otherwise it simply returns the physical connection.

For example, if I am using the ResetAbandonedTimer interceptor and need to take advantage of an Oracle specific method in oracle.jdbc.OracleConnection I would like to be able to invoke:

OracleConnection oraCon = connection.unwrap(OracleConnection.class);
oraCon.someOracleSpecificCommand();

my use of oraCon could still invoke ResetAbandonedTimer.

Or if I were to invoke oraCon.close() this should correctly return this connection to the pool.

FYI, this is how Websphere's connection pool implements unwrap.


2.  When creating the original connection in org.apache.tomcat.jdbc.pool.ConnectionPool.getProxyConstructor() include in the proxied interfaces any interfaces the native connection also implements.  That way I wouldn't need to unwrap the tomcat-jdbc provided connection since it will already implement the native connection's interfaces.

FYI, this is how Oracle UCP works.

Thoughts?  I'd be happy to provide a patch if the functionality is desirable.

Mike
Comment 1 Filip Hanik 2012-03-20 15:49:26 UTC
patch and test cases would be helpful