commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: [DBCP] Example of SharedPooledDataSource with JNDI
Date Wed, 16 Jun 2004 22:48:13 GMT

Its looking good - just what I wanted.

The one issue I have now is trying to decipher a failure I have when I
have 2 different concurrent Datasources in the JVM.

I build and register an Oracle and a DB2 DataSource as you have
documented, though using SharedPoolDataSource rather than
PerUserPoolDataSource in both cases.

InstanceKeyObjectFactory.getObjectInstance() can do an
instanceMap.put(key, ds);
under some circumstances where key = eg: "jdbc/oDS"

InstanceKeyObjectFactory.registerNewInstance()is also doing
instanceMap.put(instanceKey, ds);
where key = eg: "1" (asserted from int max)

However there is code in InstanceKeyObjectFactory.registerNewInstance()
to determine
a new instanceKey and it expects every key in instanceMap to be numeric:

        while (i.hasNext()) {
            Object obj =;
            if (obj instanceof String) 
                max = Math.max(max, Integer.parseInt((String)obj));

Since there are keys like "jdbc/oDS" in the collection in additon to
keys like "1"
a NumberFormatException occurs when the second DataSource is first

No doubt this is a usage or setup problem but I haven't figured it out
I do know that it works fine if I trap and ignore the
It also works fine if only one DataSource is registered since from the
2nd time on
the lookup on the key (eg jdbc/oDS) works so there are no further
registrations required (registerNewInstance())

Any illumination would be helpful.

Thanks for all the help.

Creighton Malet
SBC Services, Inc.

-----Original Message-----
From: Dirk Verbeeck [] 
Sent: Wednesday, June 16, 2004 12:32 PM
To: Jakarta Commons Users List
Subject: Re: [DBCP] Example of SharedPooledDataSource with JNDI

OK, I have been looking how tomcat & naming are using DBCP with JNDI.

I have made a page with 2 example:

Let me know if this works for you.
Improvements are also welcome ;-)


> No, I'm not trying to cross VMs. Sorry, terminology, I'm using server
> mean container, and client to mean application; but its all in the
> VM.
> Its precisely that container like behavior I'm looking for - create
> bind the pool into JNDI at startup and the application does a JNDI
> lookup for the Datasource from which it gets the connection.
> Thanks
> ------------
> Creighton Malet
> SBC Services, Inc.
> (925)823-1463

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

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

View raw message