Reputation: 581
I'm getting connection pool issue when I try to post to the Database
here what I'm using for context xml file
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
maxActive="10"
initialSize="0"
maxAge="1800"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="SELECT 1"
validationInterval="30000"
timeBetweenEvictionRunsMillis="30000"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
minEvictableIdleTimeMillis="18000"
jmxEnabled="true"
fairQueue="true"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer;
org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
the Error:
Caused by: org.apache.tomcat.jdbc.pool.PoolExhaustedException: [ajp-nio-0.0.0.0-8009-exec-3] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:10; busy:10; idle:0; lastwait:30000].
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:710) ~[tomcat-jdbc.jar:?]
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198) ~[tomcat-jdbc.jar:?]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:132) ~[tomcat-jdbc.jar:?]
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157) ~[spring-jdbc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115) ~[spring-jdbc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78) ~[spring-jdbc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
I have this working working before, then suddenly it stops working, Is there something I'm missing to add or update in my config?
Upvotes: 0
Views: 339
Reputation: 1083
There can be different reasons why your connectionpool is exausted. If you are using a framework that connects to your mysql database check the recommended pool configuration.
Also make sure to close your connections properly.
The try-with-resources Statement: try with resources
a reasonable config could look like this:
<Resource type="javax.sql.DataSource"
...
initialSize="10"
maxActive="100"
maxIdle="50"
minIdle="10"
...
/>
Upvotes: 1