zoukankan      html  css  js  c++  java
  • MySql的autoReconnect与autoReconnectForPools属性对比

    autoReconnect会向客户端抛出一个SQLException,但会尝试重新建立连接。
    autoReconnectForPools将在每次执行SQL之前尝试ping服务器。
    autoReconnect和autoReconnectForPools并没有什么关系。并且MySql官方并不推荐使用autoReconnect属性。


    autoReconnect
    

    Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, as a last option, investigate setting the MySQL server variable "wait_timeout" to a high value, rather than the default of 8 hours.

    Default: false

    Since version: 1.1

    官方已经说明了:如果启用这个属性,则MySQL驱动程序将会对当前事务的已过期或者已被废弃的链接发出的查询请求抛出异常,并会在发起下一次请求之前尝试重新建立连接。官方已经不建议使用该属性,该值只建议在应用程序无法正确处理死链或已被回收的链接所导致的SQLException时使用。
    解决该问题的最有方法就是调整MySQL的wait_timeout参数,使之大于8个小时。

  • 相关阅读:
    Python学习--not语句
    【图论】有向无环图的拓扑排序
    算法精解:DAG有向无环图
    Python xrange() 函数
    自然语言处理课程(二):Jieba分词的原理及实例操作
    Jieba分词原理与解析
    ios面试题整理
    OC语言Block和协议
    OC内存管理
    IOS 开发-- 常用-- 核心代码
  • 原文地址:https://www.cnblogs.com/LoveShare/p/12209063.html
Copyright © 2011-2022 走看看