1. 程式人生 > >資料庫連線超時The driver has not received any packets from the server

資料庫連線超時The driver has not received any packets from the server

一、問題今天Linux跑專案的時候,啟動tomcat報錯提示:...last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.大概意思就是mysql連線超時二、解決辦法1、使用JDBC URL中使用autoReconnect屬性,url追加紅色部分內容
jdbc.url=jdbc:mysql://192.168.0.109:3306/test?useUnicode=true&characterEncoding=utf8
&autoReconnect=true&failOverReadOnly=false
2、修改MySQL的引數vim /etc/my.cnf,在[mysqld]後面新增以下內容(365天=31536000秒)
wait_timeout=31536000interactive_timeout=31536000
3、重啟mysql
#service mysql restart