You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Scott <mi...@linkline.com> on 2003/06/05 19:57:56 UTC
Sharing a connection pool among contexts
Hi, I have configured the commons-dbcp datasource as a JNDI resource for
MSSQL and Oracle and all is working as expected. However, as I understand,
it is only possible to keep a factory as a resource and so a new datapool
must be created everytime a JNDI lookup is done. I would like to share a
single connection pool among different contexts.
My first attempt was to create a listener that put a single instance of a
pool into the JNDI only to find that it is read-only. For my next attempt I
am thinking of creating a javabean with a static collection of datasources
and name keys that can be gotten as a JNDI resource so that the different
applications can just retrieve the bean and do a lookup of the datasource
that way.
Am I missing an easier or better way to do this? I do not have any
experience with Javabeans and based on the stuff I've seen on the web beans
are usually graphic oriented. Is this an appropriate use of a bean (or
perhaps an Enterprise Javabean)?
Thank you in advance,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Sharing a connection pool among contexts
Posted by Emerson Cargnin <em...@tre-sc.gov.br>.
I do it in a different way :
I have a servlet in charge to set all pools, and I have a class with
statics methods to manage the pools, creating, test, and show their use.
This class is shared with all contexts through a jar in common/lib.
So I have a servlet, with all configuration of the pools in param in the
web.xml. this servlet can create pools (in its init method), test and
show it, and show statistics.
I works great, and I can share a pool among contexts.
I use the bitmechanic connection pool, a little old, but still works.
http://www.bitmechanic.com/projects/jdbcpool/dist/jdbcpool-1.0b1.zip
I put the jar of the pool in the common/lib dir. I f anyone is
interested in the ConnectionManager, I can share it, it's an eclipse
project with ant build file that generates both war and the lib jar.
Hope it can help :)
Emerson
Scott wrote:
> Hi, I have configured the commons-dbcp datasource as a JNDI resource
> for MSSQL and Oracle and all is working as expected. However, as I
> understand, it is only possible to keep a factory as a resource and so
> a new datapool must be created everytime a JNDI lookup is done. I
> would like to share a single connection pool among different contexts.
>
> My first attempt was to create a listener that put a single instance
> of a pool into the JNDI only to find that it is read-only. For my next
> attempt I am thinking of creating a javabean with a static collection
> of datasources and name keys that can be gotten as a JNDI resource so
> that the different applications can just retrieve the bean and do a
> lookup of the datasource that way.
>
> Am I missing an easier or better way to do this? I do not have any
> experience with Javabeans and based on the stuff I've seen on the web
> beans are usually graphic oriented. Is this an appropriate use of a
> bean (or perhaps an Enterprise Javabean)?
>
> Thank you in advance,
> Scott
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
Emerson Cargnin
Analista de Sitemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org