You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by pq...@shareowner.com on 2002/12/18 18:24:47 UTC

RE: tomcat jndi + commons-dbcp problem - to Craig

Thanks Craig.
 
- I did setup according to the one you mentioned in your posting, web.xml,
server.xml.
- I never got any answer from tomcat user list. Since my issue deals with
commons-dbcp, I posted here instead.
- A typo in my posting, it should be javax.sql.DataSource.
- I placed jdbc2_0-stdext.jar in my application's WEB-INF/lib folder and
classes12.jar in $CATALINA_HOME/common/lib
- The connection returned is org.apache.commons.dbcp.PoolableConnection
neither OraclePoolableConnection nor OracleConnection
 
Question, is org.apache.commons.dbcp.BasicDataSource smart enough to return
an driver-specific connection, in this case, OraclePoolableConnection or
OracleConnection?
 
My web.xml
 
<resource-ref>
            <description>Oracle Datasource</description>
            <res-ref-name>jdbc/abcd</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
</resource-ref>
 
My server.xml
 
<Resource name="jdbc/abcd" auth="Container" type="javax.sql.DataSource"/> 
<ResourceParams name="jdbc/abcd">
<parameter>
            <name>driverClassName</name>
            <value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
            <name>url</name>
            <value>jdbc:oracle:thin:@test:1521:PROD</value>
</parameter>
<parameter>
            <name>username</name>
            <value>web</value>
</parameter>
<parameter>
            <name>password</name>
            <value>web</value>
</parameter>
<parameter>
            <name>maxActive</name>
            <value>20</value>
</parameter>
<parameter>
            <name>maxIdle</name>
            <value>30000</value>
</parameter>
<parameter>
            <name>maxWait</name>
            <value>-1</value>
</parameter>
<parameter>
            <name>removeAbandoned</name>
            <value>true</value>
</parameter>
<parameter>
            <name>removeAbandonedTimeout</name>
            <value>60</value>
</parameter>
</ResourceParams>
 
 
 
Regards,
 
 
 
Phillip Qin
 
"This Guy Thinks He Knows Everything"
Canadian Shareowner
121 Richmond Street W, 7th Floor
Toronto, ON M5H 2K1
(416) 595-9600 ext 291
 

RE: tomcat jndi + commons-dbcp problem - to Craig

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 18 Dec 2002 pqin@shareowner.com wrote:

> Date: Wed, 18 Dec 2002 12:24:47 -0500
> From: pqin@shareowner.com
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: commons-user@jakarta.apache.org
> Subject: RE: tomcat jndi + commons-dbcp problem - to Craig
>
> Thanks Craig.
>
> - I did setup according to the one you mentioned in your posting, web.xml,
> server.xml.
> - I never got any answer from tomcat user list. Since my issue deals with
> commons-dbcp, I posted here instead.
> - A typo in my posting, it should be javax.sql.DataSource.


> - I placed jdbc2_0-stdext.jar in my application's WEB-INF/lib folder and
> classes12.jar in $CATALINA_HOME/common/lib

The first part of this is a mistake.  The jdbc2_0-stdext.jar file is
already there in common/lib, and should *not* be installed in your webapp.

> - The connection returned is org.apache.commons.dbcp.PoolableConnection
> neither OraclePoolableConnection nor OracleConnection
>
> Question, is org.apache.commons.dbcp.BasicDataSource smart enough to return
> an driver-specific connection, in this case, OraclePoolableConnection or
> OracleConnection?
>

You should be casting the returned connection object to
java.sql.Connection, and not trying to worry about it's internal Oracle
implementation class name.  The object returned by commons-dbcp is a
wrapper around whatever Connection implementation your JDBC driver
returns.

Craig