Issue
I have configured my Tomcat 9 to keep a database pool using the server.xml in order to have a minimum of 50 connections to my mysql database. When the tomcat starts I can see all the connections there with the command SHOW PROCESSLIST. I can't figure out why after a couple of days I only see 8 connections.
This is my configuration. I have included parameters whose name has changed along different tomcat versions, for example maxActive and maxTotal, to ensure that the parameter value is taken.
<Resource
name="MySqlDS"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
url="jdbc:mysql://localhost:3306/MYDB?zeroDateTimeBehavior=convertToNull"
username=*****
password=*****
initialSize="50"
maxActive="100"
maxTotal="100"
minIdle="50"
maxIdle="100"
maxWaitMillis="10000"
maxWait="10000"
maxAge="0"
minEvictableIdleTimeMillis="60000"
timeBetweenEvictionRunsMillis="30000"
suspectTimeout="60"
validationQuery="SELECT 1"
validationInterval="30000"
testOnBorrow="true"
removeAbandoned="true"
removeAbandonedOnBorrow="true"
removeAbandonedOnMaintenance="true"
removeAbandonedTimeout="60"
logAbandoned="true"
/>
What can be happening? It's my configuration wrong?
I use mysql-connector-java-5.1.13 and OpenJDK 1.8.0_275
Solution
I solved the issue adding this parameter:
testWhileIdle="true"
Answered By - serxio
Answer Checked By - Mary Flores (JavaFixing Volunteer)