tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Perrone <jason.perr...@blueskytech.com>
Subject RE: Casting a Connection as an OracleConnection in Tomcat 7
Date Fri, 02 Dec 2011 20:23:09 GMT
So, I can't cast the connection Tomcat returns as a DelegatingConnection.  DelegatingConnection
is from Commons DBCP and this connection is org.apache.tomcat.dbcp.dbcp.PoolableConnection.
 I do not want to reference any Tomcat libraries directly because our product is container
agnostic.  Any suggestions would be greatly appreciated.

Thank you.


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Tuesday, November 29, 2011 5:08 PM
To: Tomcat Users List
Subject: Re: Casting a Connection as an OracleConnection in Tomcat 7

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jason,

On 11/29/11 2:34 PM, Jason Perrone wrote:
> Has anyone yet figured out how to cast the PoolableConnection that 
> Tomcat 7 now returns when you get a Connection from a DataSource as an 
> OracleConnection?

If you are using the standard pool (which uses DBCP under the hood), I think you get use getInnermostDelegate
after casting to DelegatingConnection. That thing that gets returned should be an OracleConnection.

You also might need to set accessToUnderlyingConnectionAllowed on the DataSource in order
to actually call getInnermostDelegate. See the DBCP configuration page and look for that setting
for more info.

As always, remember to close the connection you got from the DataSource, not the inner delegate,
or you will be toast.

> In Tomcat 6 the connection was returned as T4CConnection and had no 
> problem being cast as an OracleConnection. Now, I just can't figure it 
> out. Tried using the Commons DBCP package to get native JDBC 
> connections, and every other thing I found by Googling it.

What did you actually try? What is the runtime type of the Connection object returned from
DataSource.getConnection? For me, it's BasicDataSource.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7VV8wACgkQ9CaO5/Lv0PDTOgCgqC3q35DFDoGaCGsdWwnRfN48
k5gAn3J+wzFTrzN3kmrsLWDAnLxHNxBo
=ro6R
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org

Mime
View raw message