数据库连接中断-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
包括: 验证链接有效性等等
数据库连接中断-spring-springBoot的更多相关文章
- kettle 数据库连接中断重置
项目适用kettle作为etl工具,源数据库为mysql库,目标库为oracle.在持续的循环调度中,经常发现oracle的数据库连接中断,需要重置. 具体报错信息如下: INFO 26-12 23 ...
- spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available
我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.b ...
- Spring SpringBoot和SpringCloud的关系
Spring SpringBoot和SpringCloud的关系 Spring Cloud 是完全基于 Spring Boot 而开发,Spring Cloud 利用 Spring Boot 特性整合 ...
- 接近8000字的Spring/SpringBoot常用注解总结!安排!
0.前言 大家好,我是 Guide 哥!这是我的 221 篇优质原创文章.如需转载,请在文首注明地址,蟹蟹! 本文已经收录进我的 75K Star 的 Java 开源项目 JavaGuide:http ...
- Spring/SpringBoot常用注解总结
转自:[Guide哥] 0.前言 可以毫不夸张地说,这篇文章介绍的 Spring/SpringBoot 常用注解基本已经涵盖你工作中遇到的大部分常用的场景.对于每一个注解我都说了具体用法,掌握搞懂,使 ...
- Spring全家桶相关文章汇总(Spring,SpringBoot,SpringData,SpringCloud)
因为Spring框架包含的组件比较多,写的博客内容也比较多,虽然有分专栏但是依然不方便查找,所以专门用一篇文章来记录相关文章,会不定期更新. 一.Spring 1.基础内容 Spring介绍 Sp ...
- spring springboot websocket 不能注入( @Autowired ) service bean 报 null 错误
spring 或 springboot 的 websocket 里面使用 @Autowired 注入 service 或 bean 时,报空指针异常,service 为 null(并不是不能被注入). ...
- 【记录】spring/springboot 配置mybatis打印sql
======================springboot mybatis 打印sql========================================== 方式 一: ##### ...
- Rabbitmq 整合Spring,SpringBoot与Docker
SpringBootLearning是对Springboot与其他框架学习与研究项目,是根据实际项目的形式对进行配置与处理,欢迎star与fork. [oschina 地址] http://git.o ...
随机推荐
- Python—程序设计:单例模式
单例模式 单例模式(Singleton Pattern)属于创建型模式,它提供了一种创建对象的最佳方式.这种模式涉及到一个单一的类,该类负责创建自己的对象,同时确保只有单个对象被创建,并提供一种访问其 ...
- gradle配置多个代码仓库repositories
repositories { mavenCentral() maven { url "https://jitpack.io" } maven { url "http:// ...
- tableau 和 R 的连接
1.安装R包Rserve 2.tableau帮助-管理外部服务连接,单击测试按钮出现成功连接即是通信成功. 3.创建新工作表,设置id字段,针对id记录数创建计算字段Rrand.将Rrand拖入行维度 ...
- "Mathematical Analysis of Algorithms" 阅读心得
"Mathematical Analysis of Algorithms" 阅读心得 "Mathematical Analysis of Algorithms" ...
- 20.docker 持久化存储与数据共享
1.image layer 和 container layer 的关系 image layer 是可读的 container layer 是在image layer 之上创建的 一个可读可写层 con ...
- 基于libcurl的GET与POST(HTTP1.1)
#include <stdio.h> #include <curl/curl.h> bool getUrl(char *filename) { CURL *curl; CURL ...
- 计蒜客 方程的解数(DFS)
问题描述 输出格式 输出一行,输出一个整数,表示方程的整数解的个数. 样例输入 - 样例输出 #include <stdio.h> #include <string.h> #i ...
- MVC的异步模式
[小家Spring]高性能关键技术之---体验Spring MVC的异步模式(Callable.WebAsyncTask.DeferredResult) 基础使用篇 https://blog.csdn ...
- 应用gis笔记
接口,开发包??我要做一个移动端的,完了之后和5G挂一下钩, web/桌面/移动 C#就是.NET.... 和专业程序设计课程的区别 a kind of boring hope it helpful, ...
- ElasticSearch-The number of object passed must be even but was [1]-问题解决
ES版本:6.4.3 1.The number of object passed must be even but was [1] 问题代码: IndexRequest indexRequest = ...