Monthly Archives: May 2015

SQL exception The last packet successfully received from the server was

i’ve been seeing this SQL exception lately

SQL exception The last packet successfully received from the server was 37,662,089 milliseconds ago. The last packet sent successfully to the server was 37,662,143 milliseconds ago. is longer than the server configured value of ‘wait_timeout’.

on some applications, everytime this exception occured the process is stopped and the transaction is failed.
asking some of my friend who have faced this kind of error before, they recommended to update connector library, they told me that their problem were gone after they did it. but unfortunately it didn’t work for me. so i had to do some googling, and found this one

http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql
Solving a “communications link failure” with JDBC and MySQL

in the post itself the writer wrote that there are some solutions that may work, while other may not work for the same SQL Exception message.

for me so far the solution is to use these property

  • validationQuery property
  • AutoReconnect

add this line to our dcbj configuration in context.xml
validationQuery=”SELECT 1″ testOnBorrow=”true”

and modify url by adding “autoReconnect=true”
url=”jdbc:mysql://127.0.0.1:3306/dbname?autoReconnect=true”