your mysql-connector version and database version are different. you have to use same connector version of database version. use mysql-connector-java-5.7.24.jar instead of mysql-connector-java-5.1.21.jar
Also there’s connection timeout happened in your case.
Configure the connection string with autoReconnect=true
. This is a property of the URL connection string, which works at the driver level. You need to change the connection string in the data source configuration.
You need to set the database connection url like this:
url="jdbc:mysql://localhost:3306/confluence?autoReconnect=true"
Increase the timeout. This is normally a property of the database. You can increase this value to see if you get less connection abort.
set session wait_timeout=3600;
Configure the connection pool to test the connection validity. This is done at the pool, not a the driver level. This will depend on the data source implementation that you use. But it should be configurable in the property of the data source.
Also you can refer tomcat connection pool docs:
https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Attributes
Also enable validationQuery, testWhileIdle, testOnBorrow properties.
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" name="jdbc/xxxxxxxx" type="javax.sql.DataSource" username="xxxxxxxx" password="xxxxxxx" url="jdbc:mysql://localhost:3306/xxxxxxx" validationQuery="/* ping */ SELECT 1" testWhileIdle="true"/>
Additionally enable attributes like maxTotal, maxIdle and maxWaitMillis in connection pool settings. Refer below settings for reference: