This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connection Pooling - Passing your pool to the application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection Pooling - Passing your pool to the application" Watch "Connection Pooling - Passing your pool to the application" New topic
Author

Connection Pooling - Passing your pool to the application

Bobby Cunningham
Greenhorn

Joined: Dec 08, 2005
Posts: 7
***** My environment *****
JDK - 1.5
App Server - Tomcat 5.5
Database - Sysbase
Framework - Struts

***** My question *****
When my application starts we kickoff a Startup Servlet that extends HttpServlet. In this servlet I initialize the DB Pool with a min of 5 connections. This creates a pool that stores the connections. So the only use of our servlet is to init the application.

How do you pass the pool object to the rest of the application? What is the best way to handle this? Please help. . .
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Usually, you configure the connection pool in Tomcat (in one of the XML configuration files). Tomcat will register the pool in JNDI, and you'll use JNDI in your application to lookup the pool (in the form of a DataSource object).

The Tomcat documentation explains in detail how to do this:
JNDI Datasource HOW-TO


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Pooling - Passing your pool to the application
 
Similar Threads
Store Connection Pool
Variables scope
Tomcat exception
Database Connection Pooling initialization with dbcp
Close connection