commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Dietrick <>
Subject JNDI Datasource pooling
Date Tue, 07 Jan 2003 01:26:55 GMT
I'm trying to get a MySQL JDBC connection pool configured in Tomcat 
using JNDI, and I'm having a bit of trouble.

I followed the instructions at 
and I seem to have a *single* valid connection to the MySQL database.  I 
was hoping, however, to see multiple connections open to the remote 
database machine.  When I run 'netstat -n | grep 3306' while Tomcat is 
under a sustained load, I only see a single JDBC connection.  All of my 
requests are being handled properly (i.e. the database connection is 
working), but I'm worried that I'm not getting optimal performance 
because of the single connection.

I veered from the instructions referred to above in that I assigned the 
dataSource (once initialized) to an attribute of a singleton, which I 
thought would act as the manager for my connection pool.  Is this 
proper/valid usage?  Or should I do the JNDI lookup every time I need a 

In other words, may the following code be performed only once (at 
startup)?  Or should I do it for each request which needs a DB connection?

       Context ctx = new InitialContext();
       DataSource ds = 		

Also, is org.apache.commons.dbcp.BasicDataSourceFactory (from the 
example) a poolable DataSourceFactory?  Or should I be using something else?



View raw message