zoukankan      html  css  js  c++  java
  • 数据库连接中断-spring-springBoot

    问题:据库和应用在同一台机,数据库用mysql5.6.20,已经升级druid到最新的1.0.7版本,访问的是localhost的mysql,放一个晚上不访问,第二天访问就报错了,重启服务正常,错误提示:

    [Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode] with root cause
    java.net.SocketException: Software caused connection abort: socket write error
    我按照druid的示例配置了最小连接数,以及检测连接打开,但是没用的?请问怎么看druid的保持连接池最小连接的检测日志输出???我看看有没有检测连接。

    解决方案:首先更改mysql的wait_timeout是不好的。

    用如下配置可以解决:


    <property name="validationQuery" value="select 'x'" />
    <property name="testWhileIdle" value="true" />
    <property name="testOnBorrow" value="false" />
    <property name="testOnReturn" value="false" />
    <property name="timeBetweenEvictionRunsMillis" value="600000" />
    testWhileIdle:建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于
    timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
    testOnBorrow:申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。

    testOnReturn:归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能

    参考:http://www.oschina.net/question/928524_165510

    http://itindex.net/detail/50100-druid

    springBoot数据库连接池常用配置

    参考: https://www.cnblogs.com/gslblog/p/7169481.html

    包括: 验证链接有效性等等

  • 相关阅读:
    Android带头像的用户注册页面
    Android——四种AterDialog
    Android Studio如何显示行号
    月下载量上千次的APP源码分享
    Android——列表视图(ListView)
    Android——列表选择框(Spinner)
    Android——按钮的事件监听
    ACM——第几天
    Android——控制UI界面
    Android——将图片加入到系统相册里面
  • 原文地址:https://www.cnblogs.com/daixianjun/p/mysql-config.html
Copyright © 2011-2022 走看看