Hi,

I had a look at the tomcat dbcp documentation and found that it is possible
to retrieve the underlying connection.

As described here http://commons.apache.org/dbcp/configuration.html

The problem i am getting now is that i still cannot cast the class properly
to get the underlying connection.

As described in the docs i added the following property in the datasource
definition

[code]
accessToUnderlyingConnectionAllowed="true"
[/code]

My datasource definition now looks like this

[code]
<Resource name="jdbc/testdb" auth="Container"
              type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@10.10.10.10:1521:testdb"
              username="testuser" password="testuser" maxActive="20"
maxIdle="10"
              maxWait="-1" accessToUnderlyingConnectionAllowed="true"/>
[/code]

And change my code slightly to be

[code]
Connection conn = ds.getConnection()
Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
[/code]

The problem i have now is i am getting a class cast execption on the second
line (where i am trying to getInnermostDelegate().

Here is the error i am getting

[code]
java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
    at
com.bt.ccs21.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:250)
    at
com.bt.ccs21.presentation.events.consignment.search.SubmitDeclaration.midAction(SubmitDeclaration.java:105)
    at
com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:67)
    at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
    at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

[/code]

Thanks

On Thu, Oct 9, 2008 at 5:53 PM, Ziggy <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I originally only had it on $TOMCAT_HOME/common/lib but it didnt work.
> I only put it on both locations to test it out.
>
> I have now removed the copy from $APPLICATION_ROOT_DIR/WEB-INF/ lib/ and i
> still have the same problem described below.
>
> Thanks
>
>
> On Thu, Oct 9, 2008 at 5:35 PM, Caldarale, Charles R <
> [EMAIL PROTECTED]> wrote:
>
>> > From: Ziggy [mailto:[EMAIL PROTECTED]
>> > Sent: 2008 October 09, Thursday 11:12
>> > org.apache.tomcat.dbcp.dbcp.PoolingDataSource
>> >
>> > I have placed the jdbc driver on both the following directories
>> > [code]
>> > $TOMCAT_HOME/common/lib/
>> > $APPLICATION_ROOT_DIR/WEB-INF/lib/
>>
>> > [/code]
>>
>> Never, never, never put the same class(es) in more than one location in a
>> given branch of the classloader tree.
>>
>> Since you're using Tomcat to manage the DB connection pool, the .jar file
>> containing the JDBC driver classes must be placed in common/lib.
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>> MATERIAL and is thus for use only by the intended recipient. If you received
>> this in error, please contact the sender and delete the e-mail and its
>> attachments from all computers.
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>

Reply via email to