This is the error message that we received when we migrated Java web application from an old server to new server. Fully working application when moved to new server, started giving this connectivity issue.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Source Server Configuration
- Ubuntu Linux 16.04.6 LTS build around year 2017
- PHP Version 7.0.33
- Apache 2.4.18
- mysql Ver 14.14 Distrib 5.7.29
- Java 1.8.0_242-8u242-b08
- Apache Tomcat/8.5.16
Target Server Configuration
- Ubuntu Linux 24.04 LTS
- PHP Version 8.3.6
- Apache/2.4.58
- Mariadb Ver 15.1 Distrib 10.11.7
- Java 11.0.23
- Apache Tomcat/10.1.19
Possible explanation
We were using the same pure jdbc mysql data driver that was available in the source installation. Ideally it should work with mariadb as the core is same and we are not using any new feature from the mariadb. But for some reason old mysql jdbc driver was not working. (mysql-connector-java-5.1.28-bin.jar)
One Possible Solution
It can be the bug in the new mariadb server for legacy network connectivity support. But we were able to solve this problem by downloading and using new Mariadb pure jdbc driver. (mariadb-java-client-3.3.3.jar) Download Link Here
updated the context.xml in /META-INF folder with the latest driver name
driverClassName="org.mariadb.jdbc.Driver"
Also updated the connection url with mariadb driver details
url="jdbc:mariadb://localhost:3306/database?autoReconnect=true"
IT WORKS!!!
Leave a Reply