If your debugger or a conn.getClass().getName() gives you the same classname but you are still getting a ClassCastException then there are 2 versions of the oracle class loaded by a different classloader.

Probably one in WEB-INF/lib and one in a tomcat lib directory.

Make sure you only have one copy of the oracle jars in your classpath.

-- Dirk


Mauricio Aristizabal wrote:

Hello all,

I am trying to get the actual Oracle connection or statement from the dbcp pool, because I'm trying to use an oracle-specific feature (registerIndexTableOutParameter()), but I cannot cast the underlying connection even after using getInnermostDelegate() to get the wrapped connection. I am using Tomcat 5.5 and whatever commons library came with it.

I found this article with some helpful info:
http://forum.java.sun.com/thread.jspa?forumID=48&messageID=1326953&threadID=326031



This is what I'm doing:
OracleConnection oc = (OracleConnection) ((DelegatingConnection) c).getInnermostDelegate();


If i break on that line my debugger shows the previous statement to return:
[EMAIL PROTECTED]

but I still get this exception when I continue:
java.lang.ClassCastException: oracle.jdbc.driver.OracleConnection


I've also tried to get innermost and cast statement itself:
(oracle.jdbc.driver.OracleCallableStatement)((DelegatingCallableStatement) stmt).getInnermostDelegate()


and again, debugger indicates I have what i want:
[EMAIL PROTECTED]

but still exception is thrown:
java.lang.ClassCastException: oracle.jdbc.driver.OracleCallableStatement


This is what I want to do with the OracleStatement (works fine on Weblogic with same driver):
ostmt.registerIndexTableOutParameter(3,1000, Types.VARCHAR, 300);


Here's my context setup:
<Context path="/OfferCode" docBase="OfferCode"
debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/devdb1b" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@10.176.50.65:1521:SERV"
username="asdfasdf" password="asdf" maxActive="20" maxIdle="10"
maxWait="-1" accessToUnderlyingConnectionAllowed="true"/>
<ResourceParams name="jdbc/devdb1b">
<parameter>
<name>accessToUnderlyingConnectionAllowed</name>
<value>true</value>
</parameter>
</ResourceParams>
</Context>

Thanks in advance for lending us a hand.

-Mauricio



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to