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 McClanahan <sc...@trnswrks.com> on 2008/01/04 17:05:22 UTC

jdbc connection pooling

We are about to start testing the jdbc connection pooling capabilities
within tomcat.  I don't have any control over the application instead
perform only administrative duties.  Between the developers and myself
we have done a good bit of research and mapped out a decent plan but
there is one unresolved dispute between us.  The developer says that the
jar file containing the database driver should be published within the
web applications WEB-INF/lib folder while I say it should be in
$CATALINA_HOME/common/lib.  Who is right and why?  

We hoped to define the datasource as a Resource within a DefaultContext
element in the server.xml so it is available to all web applications.
Is this good practice?  I'd like to know of some ways you folks have
done it too if you've got the time.

Also any gotchas to look out for with connection pooling would be
helpful from those who have actually done it.  Thanks.


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


Re: jdbc connection pooling

Posted by Scott McClanahan <sc...@trnswrks.com>.
On Fri, 2008-01-04 at 14:12 -0200, Diego wrote:
> I'm using the connection pooling on Tomcat 6.
> 
> And in my case i had to put the jar from the jdbc driver on.
> 
> $CATALINA_HOME/lib
> 
> On Jan 4, 2008 2:05 PM, Scott McClanahan <sc...@trnswrks.com>
> wrote:
> 
> > We are about to start testing the jdbc connection pooling capabilities
> > within tomcat.  I don't have any control over the application instead
> > perform only administrative duties.  Between the developers and myself
> > we have done a good bit of research and mapped out a decent plan but
> > there is one unresolved dispute between us.  The developer says that the
> > jar file containing the database driver should be published within the
> > web applications WEB-INF/lib folder while I say it should be in
> > $CATALINA_HOME/common/lib.  Who is right and why?
> >
> > We hoped to define the datasource as a Resource within a DefaultContext
> > element in the server.xml so it is available to all web applications.
> > Is this good practice?  I'd like to know of some ways you folks have
> > done it too if you've got the time.
> >
> > Also any gotchas to look out for with connection pooling would be
> > helpful from those who have actually done it.  Thanks.
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> 
> 

My apologies, we are running tomcat 5.0.28 on linux. 


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


Re: jdbc connection pooling

Posted by Diego <di...@gmail.com>.
I'm using the connection pooling on Tomcat 6.

And in my case i had to put the jar from the jdbc driver on.

$CATALINA_HOME/lib

On Jan 4, 2008 2:05 PM, Scott McClanahan <sc...@trnswrks.com>
wrote:

> We are about to start testing the jdbc connection pooling capabilities
> within tomcat.  I don't have any control over the application instead
> perform only administrative duties.  Between the developers and myself
> we have done a good bit of research and mapped out a decent plan but
> there is one unresolved dispute between us.  The developer says that the
> jar file containing the database driver should be published within the
> web applications WEB-INF/lib folder while I say it should be in
> $CATALINA_HOME/common/lib.  Who is right and why?
>
> We hoped to define the datasource as a Resource within a DefaultContext
> element in the server.xml so it is available to all web applications.
> Is this good practice?  I'd like to know of some ways you folks have
> done it too if you've got the time.
>
> Also any gotchas to look out for with connection pooling would be
> helpful from those who have actually done it.  Thanks.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Diego

Re: jdbc connection pooling

Posted by David Smith <dn...@cornell.edu>.
As you've described it using tomcat's JNDI resources, the driver has to 
be in common/lib.  If the application defines and manages it's own pool 
separate from tomcat, then you could put it in the app's WEB-INF/lib 
folder.  This has everything to do with how the classloaders work.  
Since tomcat and your webapp both have to have access to the driver when 
using container managed connection pools, it has to be in common/lib.

--David

Scott McClanahan wrote:

>We are about to start testing the jdbc connection pooling capabilities
>within tomcat.  I don't have any control over the application instead
>perform only administrative duties.  Between the developers and myself
>we have done a good bit of research and mapped out a decent plan but
>there is one unresolved dispute between us.  The developer says that the
>jar file containing the database driver should be published within the
>web applications WEB-INF/lib folder while I say it should be in
>$CATALINA_HOME/common/lib.  Who is right and why?  
>
>We hoped to define the datasource as a Resource within a DefaultContext
>element in the server.xml so it is available to all web applications.
>Is this good practice?  I'd like to know of some ways you folks have
>done it too if you've got the time.
>
>Also any gotchas to look out for with connection pooling would be
>helpful from those who have actually done it.  Thanks.
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


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


RE: jdbc connection pooling

Posted by Scott McClanahan <sc...@trnswrks.com>.
On Fri, 2008-01-04 at 11:16 -0600, Caldarale, Charles R wrote:
> > From: Scott McClanahan [mailto:scott.mcclanahan@trnswrks.com] 
> > Subject: RE: jdbc connection pooling
> > 
> > I'm going to try my best to not sound ignorant but can you better
> > explain what you mean when you say tomcat "manages" the connections
> > compared to if the application (using the same apache commons 
> > projects) were to manage the connections.
> 
> Functionally no significant differences, other than having Tomcat manage
> them allows them to be shared across multiple webapps.  Since the
> connection pooling logic is already included with Tomcat (and pretty
> much every other app server), there's no reason to carry that around in
> your webapp.  If you want to have pooled connections private to a
> particular webapp, then placing the driver and various commons jars in
> WEB-INF/lib would be appropriate.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

Thanks Chuck.


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


RE: jdbc connection pooling

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Scott McClanahan [mailto:scott.mcclanahan@trnswrks.com] 
> Subject: RE: jdbc connection pooling
> 
> I'm going to try my best to not sound ignorant but can you better
> explain what you mean when you say tomcat "manages" the connections
> compared to if the application (using the same apache commons 
> projects) were to manage the connections.

Functionally no significant differences, other than having Tomcat manage
them allows them to be shared across multiple webapps.  Since the
connection pooling logic is already included with Tomcat (and pretty
much every other app server), there's no reason to carry that around in
your webapp.  If you want to have pooled connections private to a
particular webapp, then placing the driver and various commons jars in
WEB-INF/lib would be appropriate.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


RE: jdbc connection pooling

Posted by Scott McClanahan <sc...@trnswrks.com>.
On Fri, 2008-01-04 at 10:23 -0600, Caldarale, Charles R wrote:
> > From: Scott McClanahan [mailto:scott.mcclanahan@trnswrks.com] 
> > Subject: jdbc connection pooling
> > 
> > The developer says that the jar file containing the 
> > database driver should be published within the web 
> > applications WEB-INF/lib folder while I say it should
> > be in $CATALINA_HOME/common/lib.
> 
> You are correct, the developer is wrong.  If Tomcat is to manage the
> connections, its internal classes must be able to see the JDBC driver
> classes.  Look at the classloader hierarchy.
> 
> Note that Tomcat 5.0.x is deprecated; you should be using a newer level.
> 
> > We hoped to define the datasource as a Resource within a
> > DefaultContext element in the server.xml so it is available
> > to all web applications.
> 
> This is not unusual, although <DefaultContext> is not used in 5.5 and
> beyond; there's a context.xml file in the conf directory instead.
> 
> > Also any gotchas to look out for with connection pooling would be
> > helpful from those who have actually done it.
> 
> Make sure the webapp code includes finally clauses on all DB access to
> make sure the connections are logically closed and thereby returned to
> the pool.
> 
>  - Chuck
> 
> 

I'm going to try my best to not sound ignorant but can you better
explain what you mean when you say tomcat "manages" the connections
compared to if the application (using the same apache commons projects)
were to manage the connections.


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


RE: jdbc connection pooling

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Scott McClanahan [mailto:scott.mcclanahan@trnswrks.com] 
> Subject: jdbc connection pooling
> 
> The developer says that the jar file containing the 
> database driver should be published within the web 
> applications WEB-INF/lib folder while I say it should
> be in $CATALINA_HOME/common/lib.

You are correct, the developer is wrong.  If Tomcat is to manage the
connections, its internal classes must be able to see the JDBC driver
classes.  Look at the classloader hierarchy.

Note that Tomcat 5.0.x is deprecated; you should be using a newer level.

> We hoped to define the datasource as a Resource within a
> DefaultContext element in the server.xml so it is available
> to all web applications.

This is not unusual, although <DefaultContext> is not used in 5.5 and
beyond; there's a context.xml file in the conf directory instead.

> Also any gotchas to look out for with connection pooling would be
> helpful from those who have actually done it.

Make sure the webapp code includes finally clauses on all DB access to
make sure the connections are logically closed and thereby returned to
the pool.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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