commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Purnima Venkatram" <>
Subject maxActive/maxWait
Date Mon, 03 Mar 2008 13:36:07 GMT
Hi all.

I am using commons dbcp through Tomcat.


1) Spring 2.5.1
2) Tomcat 5.5.25
3) mysql 5.0.21.

Have put the commons-dbcp-1.2.2.jar / commonds-pool-1.4.jar /
commonds-logging-1.0.4.jar into tomcat's common/lib.

The dataSource is accessed through a JNDI lookup. I want to check connection

For the same I tried the following for the dataSource definition.

In context.xml I have:

       auth="Container" type="javax.sql.DataSource"
       validationQuery="SELECT 1"

Setting maxActive to 1 means that only 1 connection will be allocated at the
same time. Which means that If i establish two concurrent requests to the
application, then the second one should fail. I don't see this happen. I
initially thought that I had very few rows in the db and hence the mysql
operation was finishing quickly due to which the second request was also
getting processed. But putting a loop and executing the mysql statement also
results in both the requests getting served.

I tried this with Jmeter too. I tried a Forever loop with Jmeter. And during
that time maxActive=1 and then from the browser again tried a request to the
jsp and this time I got a 'JDBC exception : Communications link failure' -
Address already in use. If i stop Jmeter tests, an redo the browser test, it
only succeeds after a while. ie the first few runs still fail with the same
exceptions and then it seems like the connections are released and then this
call succeeds. But in this time interval , in mysql 'show processlist' I
dont see the connections.

I have tried this for a lot of time and any suggestions/comments would be

I have checked the source of BasicDataSource and saw that it uses the
ObjectPool and PoolableConnectionFactory. Hence am assuming there isnt
anything else that I need to do to get pooling to work.
I also tried deleting the naming-dbcp jar from tomcat's common lib since
that seemed to have the same classes as commons-dbcp.

Is anything else required ?

In spring this is accessed using getBean and then the corresponding dao
method is called.

Also, as soon as it finishes the operation, the connection is removed from
the 'show processlist' of mysql. Does that mean , Tomcat drops and creates
connections for every call ? Isn't that against connection pooling ? Most of
the time I see the status as 'null' / 'sleep' / 'query' with validatation
query and very less time for the actual select query.

Best Regards,
Purnima Venkatram.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message