wood burning stoves*
The moose likes Tomcat and the fly likes connection pooling with Tomcat 4.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "connection pooling with Tomcat 4.0" Watch "connection pooling with Tomcat 4.0" New topic

connection pooling with Tomcat 4.0

Narsimha Manekar
Ranch Hand

Joined: Mar 05, 2001
Posts: 35
I am trying to use connection pooling with
Tomcat 4.0.6
J2SDK 1.4.0
mysql server version: 4.1.0-alpha
JDBCdriver mysql-connector-java-3.0.8-stable-bin.jar
For this I am trying to use the example provided in
but couldn't get it to work.
Could any one give me a step by step procedure to implement connection pooling with Tomcat 4.0.6 / DBCP / mysql
Thank you.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60780

Moving to the Tomcat forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sudeep philip

Joined: Nov 28, 2002
Posts: 5
I tried out the connection pool on Apache Tomcat/4.1.10 and was sucessfull. The databases which was tested was Oracle 9i and SQL Server 7/2000 databases.
Hope this will solve your problems....
1) The commons-dbcp-1.1.jar, commons-pool-1.1.jar and commons-collections.jar should be at Tomcat/common/lib folder.
2) The jdbc driver,(mysql-connector-java-3.0.8-stable-bin.jar) should be available at Tomcat/common/lib folder.
3) Add the Resource name and the following details within the context at Tomcat/conf/server.xml
<Resource name="YourPoolName" scope="Shareable" type="javax.sql.DataSource" auth="Container"/>
<ResourceParams name="YourPoolName">
<value>Database UserName</value>
<value>database password</value>
4) From the program use the following lines to access the pool.
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:/comp/env/YourPoolName");
java.sql.Connection con=ds.getConnection();
5) Restart tomcat. :-))
Note: Check for the driver and data base url. Hope this will solve your problem of creating a connection pool for tomcat.
[ January 02, 2004: Message edited by: sudeep philip ]
[ January 02, 2004: Message edited by: sudeep philip ]
I agree. Here's the link: http://aspose.com/file-tools
subject: connection pooling with Tomcat 4.0
Similar Threads
tomcat related query
JNDI in Servlets
connection pooling
load DB connection class on tomcat startup
Connection Pool/App Server