You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Newman <dn...@unixmonkeys.com> on 2014/02/07 03:26:29 UTC

Tomcat JNDI Datasource

I have defined a JNDI JDBC datasource as a resource in the global
context.xml file.  I was under the impression that what this does is to
create a shared connection pool that is tomcat wide.  But in practice what
seems to happen is that a new instance of that connection pool is created
for each context that is running in the container.  For example, if I have
6 web applications deployed I end up with 60 connections to my database,
assuming the default initialSize parameter of 10.

Is there a way to have a single connection pool that is shared amongst
deployed applications?

In case it is relevant this is tomcat 7.0.19 using the tomcat connection
pool.

Thanks
-Dave

Re: Tomcat JNDI Datasource

Posted by David Newman <dn...@unixmonkeys.com>.
On 2/6/2014 10:45 PM, Filip Hanik wrote:
> Yes, define the connection pool in server.xml, <GlobalNamingResources> then
> in context.xml define a <ContextLink> That binds the shared connection pool
> to each context.

Thank you, that worked perfectly.  Although I think you meant
<ResourceLink>.

-Dave


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


Re: Tomcat JNDI Datasource

Posted by Filip Hanik <fi...@hanik.com>.
Yes, define the connection pool in server.xml, <GlobalNamingResources> then
in context.xml define a <ContextLink> That binds the shared connection pool
to each context.



On Thursday, February 6, 2014, David Newman <dn...@unixmonkeys.com> wrote:

> I have defined a JNDI JDBC datasource as a resource in the global
> context.xml file.  I was under the impression that what this does is to
> create a shared connection pool that is tomcat wide.  But in practice what
> seems to happen is that a new instance of that connection pool is created
> for each context that is running in the container.  For example, if I have
> 6 web applications deployed I end up with 60 connections to my database,
> assuming the default initialSize parameter of 10.
>
> Is there a way to have a single connection pool that is shared amongst
> deployed applications?
>
> In case it is relevant this is tomcat 7.0.19 using the tomcat connection
> pool.
>
> Thanks
> -Dave
>