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!!
Will,
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
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html