Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a java application with following line in context.xml

<Resource 
    driverClassName="com.mysql.jdbc.Driver" 
    maxActive="100" 
    maxIdle="30" 
    initialSize="10" 
    maxWait="7000" 
    name="jdbc/app" 
    password="pass" 
    type="javax.sql.DataSource" 
    url="jdbc:mysql://dbhost:3306/dbname?autoReconnect=true" 
    username="user" 
    validationQuery="SELECT 1" 
    removeAbandoned="true" 
    removeAbandonedTimeout="30" 
    logAbandoned="true" 
/>

In mysql 'show variables' tells me that max_connections is 151.

Still,

use information_schema;
select count(*) from processlist where User = 'user';

never shows me more than 20 connections. On tomcat's catalina.out -log I get

Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
        at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:103)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)

What should I check for to find the problem?

share|improve this question
    
What tomcat version? –  mahnsc Aug 14 '11 at 0:44

3 Answers 3

And check whether the application is closing connections properly, this is the programmers stuff to do, but still a common error.

share|improve this answer

I'm not sure it is a Tomcat problem, check to see if MySQL is limiting the number of connections.

share|improve this answer

Also check MySQL's max_user_connections variable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.