File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes connection pooling/threading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "connection pooling/threading" Watch "connection pooling/threading" New topic

connection pooling/threading

Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

Is there a difference between setting up a db connection through tomcat (using the tomcat config ) and building one internally into a servlet? I'm looking to improve the performance of my project and am uncertain which path to take. Also, does the tomcat configuration affect how threading within servlets are handled? ( If so, does Pro Jakarta Tomcat 5 cover these issues? ) Thanks!

-------<br /> Aodhan H - Ad Astra Per Aspera<br /> -------
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Setup db connection through app server will create a pool of that connections. In servlet you must do this manualy.

Which performance you mean? Is your application slow or consumes much resources?

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

for my application, for each request it handles, it must make several sql queries. Sometimes multiple JDBC connection objects are created in the cycle of the request. I'm thinking of threading the sql queries to improve speed.

Regarding threading, what I want to know is whether how the container is set up, the Tomcat configuration, might impact the threading of my application.
Lee Barney
Ranch Hand

Joined: May 07, 2003
Posts: 37
The biggest issue I see with using the containers connection pooling is with portablility.

The code to create a good connection pool is fairly trivial and small. This being the case, why would I want to reduce my flexabiltiy when I could readily handle such things as the threading you mentioned as a requirement in my own code?

I know that if there were many lines of code required to create a timed self leveling pool that it would be adventageouse to use the container to do this. It is not the case that a large amount of code is required to do this so I have chosen to create my own.
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
You can use Commons DBCP and Commons DbUtils.
I agree. Here's the link:
subject: connection pooling/threading
It's not a secret anymore!