• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

connection pooling with Tomcat 4.0

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
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.
Rao
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Tomcat forum.
bear
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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">
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/dbname?autoReconnect=true</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value></value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>5</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
<parameter>
<name>username</name>
<value>Database UserName</value>
</parameter>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>password</name>
<value>database password</value>
</parameter>
</ResourceParams>
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic