commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GMail - Ugo Gagliardelli <>
Subject [dbcp] BasicDataSource.createConnectionFactory() fails
Date Tue, 10 Jan 2012 12:23:11 GMT
I'm trying to use BasicDataSource 1.3 (latest release downloaded just 
now) using a custom classloader. In other words I set a ClassLoader with 
setDriverClassLoader method.
When I try to create a connection, I get an SQL Exception from 
createConnectionFactory(). Looking at source code, I see that 
createConnectionFactory method, still use:
  driver = DriverManager.getDriver(url);
that will not use the correct classloader, infact it uses what returned 
by getCallerClassLoader(), that's a classloader not able to resolve the 
driver class.

How can I have this figure work?

This is my code (Spring based):

<bean id="propertyConfigurer"
<property name="location">

<bean id="jarClassloarder" class="">
<bean id="jarURL" class="">
<constructor-arg value="file://${db.driver.jar}"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassLoader" ref="jarClassloarder" />
<property name="driverClassName">
<property name="url">
<property name="username">
<property name="password">

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message