commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <>
Subject Re: [dbcp] need help for late configuration in multithreaded environment
Date Thu, 15 Apr 2010 00:45:27 GMT
Geronimo M. H. wrote:
> Hello,
> I changed my db-access to be user-configurable. When my app starts, it reads 
> the archive-name and driver class, the user configured and tries to setup a 
> poolable datasource from that properties.
> I'm now trapped within threads, context initialization and timings.
> The point is, when I read the user properties, that should be used for 
> datasource, the datasource instance has already been created (by the 
> context). When I load the drivers jar and class, all works well, but as soon 
> as I ask a connection from the datasource, I get an exception, which says, 
> that the driver-class could not be loaded.
> So I guess, the point is, that both actions run in different threads and I 
> don't know, how to change the classloader of an already loaded instance or an 
> unknown thread.
> Can anybody shine me a light please on what datasource to use or how to change 
> properties of an already instantiated datasource?

Sorry for the slow response.  If I understand your problem
correctly, you need to get the datasource fully initialized
(including loading the driver) when you first create it.  If you are
using the most recent release of dbcp (1.3 for jdk 1.4, 1.5 or 1.4
for jdk 1.6), and you use BasicDataSourceFactory to create the
BasicDataSource, specifying an initialsize > 0 will cause
initialization to happen at BasicDataSource creation time.  If you
are using an earlier version, you can load the driver yourself and
create a PoolingDataSource "manually" following the
ManualPoolingDataSourceExample linked on the dbcp home page

> kind regards
> Geronimo
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message