1. 程式人生 > >Communications link failure,The last packet successfully received from the server was × millisecon..

Communications link failure,The last packet successfully received from the server was × millisecon..

        具體解釋是這樣的:Mysql伺服器預設的“wait_timeout”是8小時【也就是預設的值預設是28800秒】,也就是說一個connection空閒超過8個小時,Mysql將自動斷開該connection,通俗的講就是一個連線在8小時內沒有活動,就會自動斷開該連線。而應用連線池卻認為該連線還是有效的(因為並未校驗連線的有效性),當應用申請使用該連線時,就會導致上面的報錯。


       wait timeout的值可以設定,但最多隻能是2147483,不能再大了。也就是約24.85天
所以即使你MySQL通過my.ini 在
# The TCP/IP Port the MySQL Server will listen on
port=3306下面新增
# this is myown dinifition for mysql connection timeout
wait_timeout=31536000
interactive_timeout=31536000
無論超過最大限度多大的數值,只能被MySQL解析為2147483

解決方案:

1、按照錯誤的提示,可以在JDBC URL中使用autoReconnect屬性,實際測試時使用了autoReconnect=true&failOverReadOnly=false,不過並未起作用,使用的是5.1版本,可能真像網上所說的只對4之前的版本有效。

2、增大mysql的wait_timeout屬性值;(起不到實質性作用)

show variables like '%timeout';

3、最好的解決方法,如果使用了c3p0連線池,可以配置idleConnectionTestPeriod 屬性,每多少秒檢查所有連線池中的空閒連線,把該值設定的小於mysql的wait_timeout值即可。
--------------------- 
作者:藍精靈lx 
來源:CSDN 
原文:https://blog.csdn.net/liuxiao723846/article/details/45534885 
版權宣告:本文為博主原創文章,轉載請附上博文連結!

相關推薦

Communications link failureThe last packet successfully received from the server was × millisecon..

        具體解釋是這樣的:Mysql伺服器預設的“wait_timeout”是8小時【也就是預設的值預設是28800秒】,也就是說一個connection空閒超過8個小時,Mysql將自動斷開該connection,通俗的講就是一個連線在8小時內沒有活動,就會自動

mysql重連連接丟失:The last packet successfully received from the server

sts one rac name java nes over href deb 原文地址:http://nkcoder.github.io/blog/20140712/mysql-reconnect-packet-lost/ 1.1 錯誤信息: Caused by: com

mysql重連連線丟失:The last packet successfully received from the server

問題原因: 其實上面的提示中已經給出了一部分的簡要說明,簡單來說就是: 程式啟動時,在跟DB首次互動時,獲得了相應的DB Connection資源,從而進行正常的DB讀寫操作。但是在下次進行DB讀寫時(我的定時任務本身設定的時間間隔是24小時),應用程式認為這個連線是可

(2)Mysql ----- The last packet successfully received from the server was *** millisecond ago.The

java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the

徹底解決"The last packet successfully received from the server was * milliseconds ago"問題

1.修改mysql 的 wait_timeout引數(和interactive_timeout一起) 不推薦 2.如果用hibernate.必須手動配置連線池,最好是用c3p0連線池。如果不配,會使用內建連線池。內建連線池的8小時斷開問題不知道hibernate開發者怎麼還

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from t

MySQL資料庫提示:Communications link failureThe last packet succe

Last modified:2013-10-08 14:16:47      **********************************************       web網站使用MySQL資料庫,今天突然報以下錯誤:       Communication

Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfu

全部 rip iteye toolbar 登錄 技術分享 方案 onf 17. SQL: Cannot create JDBC driver of class ‘‘ for connect URL 使用數據庫數據源的web 項目,發布後,訪問數據庫500報錯: 瀏覽器端:

Communications link failure Last packet sent to the server was 0 ms ago.問題解決

在使用Matlab連線Mysql資料庫的時候常常出現這個問題,最後發現因為使用的是網上的資料庫,通過本地的Mysql建立一個本地的工作區間,而出現上面的問題,原因很簡單,電腦沒聯網。。。。 錯誤資訊如

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server

att sed abs cte gist hang app caused ctp ? 版權聲明:本文為博主原創文章,轉載請註明出處 1.問題描述   搭建SSH框架,啟動時報錯如下: The last packet sent successfully to the ser

連結資料庫報錯(Communications link failure)之解決篇

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet

兩種解決異常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的辦法

  出現異常”The last packet sent successfully to the server was 0 milliseconds ago.“的大部分原因是由於資料庫回收了連線,而系統的緩衝池不知道,繼續使用被回收的連線所致的。            以my

Communications link failure

兩個 lur 發現 idle style mem lec 針對 .cn 針對數據庫Communications link failure的錯誤,可以理解為有兩種策略解決: 策略1(推薦): 數據池配置 <property name="minEvictableI

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

啟動 exception fail 空格 jdbc bsp 回車 數據 實現 報錯:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 很尷尬的問題,翻譯一

MySQL異常【資料庫斷開連線】:Communications link failure

一,異常資訊以及解決辦法 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure org.springframework.transaction.CannotCreateTransa

sqoop import 報錯Communications link failure

1.問題描述        sqoop list-tables 工具正常,但是import 工具有問題。奇怪!!!! [[email protected] ~]$ sqoop import --username test --passw

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

最近在空閒時間學習的時候,往伺服器上部署專案遇到無法連線資料庫,啟動報錯的問題,最後排查下來是一個簡單的配置造成的,特此記錄。 伺服器:centos 7 mysql:5.7.23 tomcat:8.5.34 jdk:1.8.0_181 說明:由於是自己練手的專案

應用端連線MySQL資料庫報Communications link failure

事情的起因: 某專案的開發同學突然Q我們組的某同學,要求我們調整MySQL的連線等待超時引數wait_timeout。要求我們從28800s調整到31536000s(也就是一年) 應用端測試環境的tomcat報錯日誌如下圖:   恩。報錯很明顯。這個問題百度後的解決方案

Oozie時出現Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

  不多說,直接上乾貨!   問題詳情 [[email protected] oozie-4.1.0-cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -run DB Connection [[email&#

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解決辦法

09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.mysql.jdbc.exceptions.jdbc4.Communicati