0

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?

David Pashley
  • 23,151
  • 2
  • 41
  • 71

3 Answers3

1

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

flo
  • 66
  • 1
0

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

Joshua
  • 779
  • 1
  • 9
  • 18
0

Also check MySQL's max_user_connections variable.

ahanson
  • 1,674
  • 2
  • 15
  • 21