Bug 51879 - Improve access to Native Connection Methods
Summary: Improve access to Native Connection Methods
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2011-09-22 23:23 UTC by Mike Youngstrom
Modified: 2012-03-20 15:49 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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);

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.

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