In c3p0 Version 0.9.1.2 the class com.mchange.v2.c3p.DriverManagerDataSource does not effectively take the driver class driverClass into account.
The Problem is that method ensureDriverLoaded() does not set driver if driverClass has been explicitly been set and successfully loaded. It solely sets the flag driver_class_loaded. Thus it is left up to method driver() to again lookup a driver. It does so via java.sql.DriverManager which accidently returns the first driver that is able to handle a given URL. If there is more than one Driver able to handle the URL it may happen that an other driver is used than the intended one, e.g. Oracle rather P6SPY driver.
Furthermore clearDriver() looks quite strange. If it really makes sense to clear the driver if the url is chaged, it should also handel a explicitly set driverClass appropriately, e.g. additionally reset the driver_class_loaded flag.
private void ensureDriverLoaded() throws SQLException
if (! isDriverClassLoaded())
if (driverClass != null)
this.driver = (Driver)Class.forName( driverClass );
setDriverClassLoaded( true );
catch (ClassNotFoundException e)
logger.log(MLevel.WARNING, "Could not load driverClass " + driverClass, e);
Log in to post a comment.