I did try getInnermostDelegate after casting to DelegatingConnection, but I did 
not set accessToUnderlyingConnectionAllowed. I will try that tomorrow. Thanks.


-----Original Message-----
From: Christopher Schultz [mailto:ch...@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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to