You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ee2_list <ee...@maxiq.ro> on 2002/06/27 15:50:48 UTC

"Scope" of the DataSource from JNDI

What is the "scope" of a (pooled) DataSource obtained via JNDI?

Tomcat 4.0.3.
Let's say we have two web-applications: /app1 and /app2
Further, there is a DataSource <Resource> defined in the <DefaultContext>.
The factory will then be accessible from both /app1 and /app2 contexts, but
(as my experiments show) each one will get a distinct instance of the
factory.

However, both should connect to the same backend database, under the same
credentials/coordinates, so I'd like to draw connections from the same pool
for both apps (actually for any app/context, for that matter).
I suspect this is not the case under the above described setup.

Is there any way to make multiple apps to draw from the same pool of
connections?

(P.S.: Yes, I am aware that the default setup is not really pooled, but I
think the question still stands.)

Thank you,
Florin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: "Scope" of the DataSource from JNDI

Posted by fva <ee...@maxiq.ro>.
Thank you.

Florin

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, June 27, 2002 07:06
Subject: Re: "Scope" of the DataSource from JNDI


>
>
> On Thu, 27 Jun 2002, ee2_list wrote:
>
> > Date: Thu, 27 Jun 2002 16:50:48 +0300
> > From: ee2_list <ee...@maxiq.ro>
> > Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> > To: Tomcat Users List <to...@jakarta.apache.org>
> > Subject: "Scope" of the DataSource from JNDI
> >
> > What is the "scope" of a (pooled) DataSource obtained via JNDI?
> >
> > <cut>
> > ..............
> > </cut>
> >
>
> In principle, the data source is scoped at the per-webapp level.  In
> Tomcat 4.0.x, there is nothing you can really do about that using JNDI.
>
> In Tomcat 4.1.x, however, there is a new feature called the "Global JNDI
> Resources" where you can put things like a data source you want to share.
> Then, in the configuration of each webapp, you put a <ResourceLink>
> element that points at the global resource (conceptually, this is a lot
> like a symbolic link on a filesystem).  Now, you'll be sharing the same
> pool.  See the "jndi-resources-howto.html", as well as the server
> configuration pages, in the 4.1 docs for more info.
>
> > Thank you,
> > Florin
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: "Scope" of the DataSource from JNDI

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 27 Jun 2002, ee2_list wrote:

> Date: Thu, 27 Jun 2002 16:50:48 +0300
> From: ee2_list <ee...@maxiq.ro>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: "Scope" of the DataSource from JNDI
>
> What is the "scope" of a (pooled) DataSource obtained via JNDI?
>
> Tomcat 4.0.3.
> Let's say we have two web-applications: /app1 and /app2
> Further, there is a DataSource <Resource> defined in the <DefaultContext>.
> The factory will then be accessible from both /app1 and /app2 contexts, but
> (as my experiments show) each one will get a distinct instance of the
> factory.
>
> However, both should connect to the same backend database, under the same
> credentials/coordinates, so I'd like to draw connections from the same pool
> for both apps (actually for any app/context, for that matter).
> I suspect this is not the case under the above described setup.
>
> Is there any way to make multiple apps to draw from the same pool of
> connections?
>
> (P.S.: Yes, I am aware that the default setup is not really pooled, but I
> think the question still stands.)
>

In principle, the data source is scoped at the per-webapp level.  In
Tomcat 4.0.x, there is nothing you can really do about that using JNDI.

In Tomcat 4.1.x, however, there is a new feature called the "Global JNDI
Resources" where you can put things like a data source you want to share.
Then, in the configuration of each webapp, you put a <ResourceLink>
element that points at the global resource (conceptually, this is a lot
like a symbolic link on a filesystem).  Now, you'll be sharing the same
pool.  See the "jndi-resources-howto.html", as well as the server
configuration pages, in the 4.1 docs for more info.

> Thank you,
> Florin
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>