-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 7/1/2010 6:06 PM, Caldarale, Charles R wrote:
>> From: Andrew Laughlin [mailto:andrew.laugh...@gmail.com]
>> Subject: Re: Implementing Connection Pooling
>>
>> The credentials for a database connection are specified per 
>> database. That is, user credentials are not used to get an 
>> authenticated connection to the database.  Notice OrgID is
>> the database name, username and password.
> 
> You're not going to be able to do this with a single <Resource>
> element, since one <Resource> == one connection pool. You'll either have
> to configure one <Resource> per OrgID (and know them all up front), or
> use your own connection pooling with commons-dbcp (or equivalent).

I agree with Chuck's analysis: Tomcat's <Resource> configuration is
intended to handle the creation of the DataSource in a fully-initialized
state. While Tomcat doesn't directly request a connection from the
DataSource, and therefore Andrew's method might actually work, it is
likely to cause problems at some level.

For instance, if you're using your DataSource for container-managed
authentication, you might not be able to set up your DataSource before
any authentication attempts are being made. Also, you may get a
connection already in the pool rather than a new connection being made,
and then your (re-)configuration is a waste of time, and may even
trigger a connection pool flush, which is of course the exact opposite
of what you want your connection pool to do.

You could possibly put the code in your initial post into a
ServletContextListener to merely configure the DataSource (and not
actually obtain a connection). When obtaining a single connection, don't
bother to set any of the properties: the DataSource is already configured.

The one question I would have for you is this: why not simply configure
a separate DataSource for each application, including all appropriate
credentials?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwtOQkACgkQ9CaO5/Lv0PChMgCfRm/oDLlgrL8zT6kcJL4/XSHT
bwMAn0o6AWFlM1D2FGoK79VEdjXanUov
=WDo1
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to