tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Laughlin <andrew.laugh...@gmail.com>
Subject Re: Implementing Connection Pooling
Date Fri, 02 Jul 2010 02:21:08 GMT
"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."

Good point Chris.  I neglected to point out that I have a custom realm that
performs authentication.

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

Because I won't have this info until run-time.

It appears Apache Commons has a GenericObjectPool class I can used to
implement my own connection pooling facility.  However I don't want to go to
the trouble if the current method actually works.



On Thu, Jul 1, 2010 at 5:55 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Chuck,
>
> On 7/1/2010 6:06 PM, Caldarale, Charles R wrote:
> >> From: Andrew Laughlin [mailto:andrew.laughlin@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message