zoukankan      html  css  js  c++  java
  • 关于MySQL的wait_timeout连接超时问题报错解决方案

    The last packet sent successfully to the server was 0 milliseconds ago.
    今天在使用JDBC操作mysql时遇到

    着实让人崩溃的信息,花费了一天的时间来解决。
    不罗嗦,直接描述解决办法。

    解决方法:



    首先一定要确定url和用户名密码是否配置正确,看看连接字串,端口是否配置正确

    然后再用网上说的URl上缀上autoReconnect=true

    jdbc:mysql://localhost:3306/oa?autoReconnect=true

     

     

    编辑mysql目录里的:my.cnf(windows下为my.ini),

    # The TCP/IP Port the MySQL Server will listen on port=3306下面添加 

    wait_timeout=31536000

     interactive_timeout=31536000



    原因分析:
    (1)大量数据访问情况下,mysql connection连接有可能失效
    (2)长时间不妨问,connection会失效

    关于MySQL的wait_timeout连接超时问题报错解决方案 
    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,2147483天后你的程序该出什么错还是什么错,避免不了

    更多参考:
    http://dev.mysql.com/doc/refman/5.1/zh/database-administration.html#dynamic-system-variables
    http://www.blogjava.net/heweiya/archive/2006/01/18/28483.html

    1 楼 连接字符串URL中,将localhost改成127.0.0.1,就OK了。
  • 相关阅读:
    某个sql帖子的答题
    JQuery hide
    JQuery tr 循环,删除td
    JQuery Disabled
    QueryString大小设置
    Silverlight HelloWorld
    USB HID通讯流程
    动态调用c++dll(转)
    VB应用程序调用c++编写的动态库(dll)(转)
    读取图像
  • 原文地址:https://www.cnblogs.com/losesea/p/3440107.html
Copyright © 2011-2022 走看看