Re: Using com.mysql.jdbc.Connection with tomcat dbcp driver connection pool
Posted by: Mark Matthews
Date: February 24, 2005 05:36PM

will crick wrote:
> Hi all,
> I am trying to implement a web app that uses the
> com.mysql.jdbc.Connection with a tomcat connection
> pool using dbcp drivers.
> When trying to return the connection object frmo
> the datasource i can get a java.sql.Connection
> object, but then cannot cast this into a
> com.mysql.jdbc.Connection object.
> The connection object returned is of type:
> org.apache.commons.dbcp.PoolableConnection - which
> implements the java.mysql.Connection interface -
> why cant i cast it?? I presume that the mysql
> Connection object does not implement some
> methods...
> see code:
> private javax.sql.DataSource queryDataSource =
> null;
> java.sql.Connection connTemp =
> queryDataSource.getConnection();
> Therefore does anyone have code samples of how to
> integrate the com.mysql.jdbc.* objects with tomcat
> connection pools??? Do i need to write my own
> connection pool?? please say no!!


You should never (well almost never) be coding against the com.mysql.jdbc.* packages, but instead against the interfaces in java.sql.*. DBCP classes implement the java.sql.* interfaces, so you should have no problems there.

Except for a few esoteric things, Connector/J doesn't have any non-standard 'vendor extension' methods on any of the implementations of the JDBC interfaces.


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Written By
Re: Using com.mysql.jdbc.Connection with tomcat dbcp driver connection pool
February 24, 2005 05:36PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.