commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MALET, CREIGHTON C (SBCSI)" <cm2...@sbc.com>
Subject RE: [DBCP] Example of SharedPooledDataSource with JNDI
Date Wed, 16 Jun 2004 22:48:13 GMT

Its looking good - just what I wanted.
Thanks.

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 = i.next();
            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
accessed.

No doubt this is a usage or setup problem but I haven't figured it out
yet.
I do know that it works fine if I trap and ignore the
NumberFormatException.
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.
(925)823-1463
cm2159@sbc.com


-----Original Message-----
From: Dirk Verbeeck [mailto:dirk.verbeeck@pandora.be] 
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:
http://jakarta.apache.org/commons/dbcp/guide/jndi-howto.html

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

Cheers
Dirk

MALET, CREIGHTON C (SBCSI) wrote:
> No, I'm not trying to cross VMs. Sorry, terminology, I'm using server
to
> mean container, and client to mean application; but its all in the
same
> VM.
> Its precisely that container like behavior I'm looking for - create
and
> 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
> cm2159@sbc.com



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message