mysql java連接異常及斷開解決秘籍



3、The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
統一加上autoReconnect=true&failOverReadOnly=false,如果是mysql 8.0,額外加上useSSL=false&serverTimezone=Asia/Shanghai。
JDBC加上驗證
validationQuery=SELECT 1
testWhileIdle=true
testOnBorrow=true
testOnReturn=true

4、The last packet successfully received from the server was 1,583 milliseconds ago. The last packet sent successfully to the server was 1,583 milliseconds ago.
timeBetweenEvictionRunsMillis=300000
minEvictableIdleTimeMillis=3600000
removeAbandoned=true
removeAbandonedTimeout=180000
logAbandoned=true

4、5 https://www.cnblogs.com/zhjh256/p/6591294.html

5、ERROR : (2006, 'MySQL server has gone away'),通常答案就https://www.cnblogs.com/fnlingnzb-learner/p/5984795.html這么幾個,1、服務器真的掛了;2、超時了(如果經過mycat,可能是mycat到mysql的連接已經超時了);3、網絡真的很不穩定。
6、2013 Lost connection to MySQL server at 'waiting for intial communication packet',system error:0 設置參數skip-name-resolve

https://dev.mysql.com/doc/refman/5.7/en/common-errors.html

1、使用最新版本的mycat,1.3、1.4 bug較多,比如com.mysql.jdbc.PacketTooBigException: Packet for query is too large (60 > -1),參見https://www.cnblogs.com/zhjh256/p/9229568.html 

1.1、對於mycat,默認的查詢超時時間300秒,如果時間很長,前端可能會出現錯誤"???",同時后台取消執行還是繼續執行??

 

可以在server.xml中調整,如下:

<system>
<!--sql超時,單位秒-->
<property name="sqlExecuteTimeout">1800</property>
</system>
建議和mysql服務器的xxx相同。
<property name="maxPacketSize">1073741824</property>
建議和mysql服務器的xxx相同。
<property name="idleTimeout">180000</property>
建議和mysql服務器的xxx相同。
<property name="txIsolation">READ-COMMITTED</property>
建議和mysql服務器的xxx相同。
其他可https://www.cnblogs.com/kingsonfu/p/10627285.html

2、使用最新版本的mysql connector
7、mysql各超時參數時間足夠長

interactive_timeout,默認28800,比wait_timeout具有更高的優先級,典型的交互式連接就是mysql自帶的客戶端,其他是C客戶端為主。

wait_timeout,默認28800,等待非交互式連接的時間

net_read_timeout,等待下一個數據包發送的時間閾值,除了WAN和網絡特別堵,基本不會發生

net_write_timeout,等待下一個數據包到來的時間閾值,除了WAN和網絡特別堵,基本不會發生

mysql、mycat配置都正確,但是delete長時間執行時報下列錯誤:

mycat.log沒有內容生成,wrapper.log大量下列錯誤:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM