Exceptions encountered by Web development:
Com.mysql.jdbc.CommunicationsException:The last packet successfully received from the server was58129 seconds ago. Thelast Packet sent successfully to the server was 58129 seconds ago, which islonger than the server configured value of ' Wait_timeout '. Should considereither expiring and/or testing connection validity before use in yourapplication, increasing the server Configured values for client timeouts, orusing the Connector/j Connection property ' Autoreconnect=true ' to avoid thisprob Lem.
Workaround:
If the connection is idle for 8 hours ( No database operation within 8 hours ), MySQL will automatically disconnect and restart Tomcat.
without hibernate , connection URL plus parameter : autoreconnect=true
with hibernate , Add the following attributes :
<propertyname= "Connection.autoreconnect" >true</property>
<propertyname= "Connection.autoreconnectforpools" >true</property>
<propertyname= "Connection.is-connection-validation-required" >true</property>
If you also use the c3p0 connection pool :
<propertyname= "Hibernate.c3p0.acquire_increment" >1</property>
<propertyname= "Hibernate.c3p0.idle_test_period" >0</property>
<propertyname= "Hibernate.c3p0.timeout" >0</property>
<propertyname= "Hibernate.c3p0.validate" >true</property>
or the most benevolent solution, is to directly modify the MySQL configuration file My.ini in the configuration file after the last increase wait_timeout=343232 The number is in seconds. it 's more convenient to change it by ten years.
Exception com.mysql.jdbc.CommunicationsException in development