Angus Mezick wrote:
>
> Interesting article, but how about using the JDBC connection pool class and
> is accessed by multiple servlets?  Do you have to write something that will
> hold the pool?  I know how to use an JNDI server for this but tomcat?

The pool described in the article uses a singleton DBConnectionManager
to
hold instances of multiple pools (implemented by the DBConnectionPool
class). A singleton is a class with only one instance, accessible
through
a static method on the class, so the pool described in the article can
be used by multiple servlets in the same application (that's kind of the
point with a pool ;-)

I wrote this article long before the web application concept was
developed. Today I would recommend that you convert the
DBConnectionManager
class into a servlet that's loaded on application start, and let it
create
and save a single instance of the DBConnectionPool class for each pool
as a servlet context attribute instead. The servlets will then get the
pool from the servlet context and ask it for a Connection directly,
instead of going through the DBConnectionManager. At application
shutdown,
the destroy() method should close all pools.

Also, more and more, database vendors provide connection pools based on
the JDBC 2.0 SE today. Typically, such a pool is handled by a JNDI
server and the application (servlet) gets a reference to it through
JNDI lookup calls. That's probably the best option if you're database
supports it.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to