关于java.sql.SQLRecoverableException: Closed Connection异常的解决方案(转)
在项目中碰到了一个应用异常,从表象来看应用僵死。查看Weblogic状态为Running,内存无溢出,但是出现多次线程堵塞。查看Weblogic日志,发现程序出现多次Time Out。
我们知道,Weblogic会自动检测线程运行超时,当超过特点时间(默认600S),即认为此线程为堵塞线程。在日志中发现多次堵塞线程,通过查找资料,发现Weblogic在发生多次线程堵塞后,会自动把应用挂起。默认次数为15次。
是什么造成了线程堵塞呢?通过进一步分析日志,我们发现在线程堵塞之前,发生了多次java.sql.SQLRecoverableException: Closed Connection异常。异常情况:
从表现来看是数据库连接出了异常。我们对数据库和网络进行了分析,确定数据库和网络都无异常。我们的另外一个应用在Weblogic运行没有类似问题。
最后在Oracle的论坛上找到了问题的根结,由于我们的应用是自己开发的数据库连接池,应用和数据库之间有一层防火墙。防火墙策略是对于1800s未使用的Socket连接将自动关闭。Oracle的日志中也发现Socket异常关闭的异常。我们对应用进行了调整,当连接池中的连接15分钟不用时,自动回收,问题解决。
http://blog.csdn.net/gavinloo/article/details/12206763
java.sql.SQLException: Io 异常: Connection reset
当数据库连接池中的连接被创建而长时间不使用的情况下,该连接会自动回收并失效,但客户端并不知道,在进行数据库操作时仍然使用的是无效的数据库连接,这样,就导致客户端程序报“ java.sql.SQLException: Io 异常: Connection reset” 或“java.sql.SQLException 关闭的连接”异常。
在配置数据源后面加上
<property name="validationQuery" value="select * from dual"/>
配置后,客户端在使用一个无效的连接时会先对该连接进行测试,如果发现该连接已经无效,则重新从连接池获取有效数据库连接来使用。
JDK1.6:
java.sql
Interface Statement:
setQueryTimeout
void setQueryTimeout(int seconds)
throws SQLException
- Sets the number of seconds the driver will wait for a
Statementobject to execute to the given number of seconds. If the limit is exceeded, anSQLExceptionis thrown. A JDBC driver must apply this limit to theexecute,executeQueryandexecuteUpdatemethods. JDBC driver implementations may also apply this limit toResultSetmethods (consult your driver vendor documentation for details). -
-
- Parameters:
seconds- the new query timeout limit in seconds; zero means there is no limit- Throws:
SQLException- if a database access error occurs, this method is called on a closedStatementor the condition seconds >= 0 is not satisfied- See Also:
getQueryTimeout()
关于java.sql.SQLRecoverableException: Closed Connection异常的解决方案(转)的更多相关文章
- 解决weblogic错误:java.sql.SQLRecoverableException: IO Error: Broken pipe
首先说一下系统基础架构: 服务器:weblogic11g集群 数据库:oracle数据库Rac 出错信息: 1.java.sql.SQLRecoverableException: Closed Con ...
- close connection error java.sql.SQLRecoverableException: IO Error: Broken pipe
java.sql.SQLRecoverableException: IO Error: Broken pipe Table of Contents 1. 错误信息 2. 分析 2.1. 连接池 2.2 ...
- java.sql.SQLException: Illegal connection port value '3306:success'
严重: Servlet.service() for servlet jsp threw exceptionjava.sql.SQLException: Illegal connection port ...
- 【异常】Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30005ms.
一.异常出现的场景 一次线上订单历史数据字段刷新操作,3张表100多万数据.由于同步更新太慢大概20分钟以上,所以采用异不的方式.代码如下: private void batchUpdate(List ...
- [ORACLE]java.sql.SQLRecoverableException: IO Error: Connection rese
随机数引起的阻塞问题 程序通过 java -jar -Djava.security.egd=file:/dev/./urandom xxx 的方式执行, http://hongjiang.info/j ...
- 在linux上通过JDBC连接ORACLE 时总是出现 java.sql.SQLRecoverableException: IO Error: Connection reset 的问题
如标题所述,经过和度娘沟通了不知道多少遍最后看一篇文章解决, 我是通过执行jar来操作DB的.所以在命令中加了一个参数( 加粗,红色) eg: $JAVA_EXE -Djava.security.eg ...
- ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: java.lang.RuntimeException: java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CO
使用sqoop导入数据时报了如题的异常,异常的提示是 The connection property 'zeroDateTimeBehavior' acceptable values are: 'CO ...
- 无法解析db.properties,spring报错:Caused by: java.sql.SQLException: unkow jdbc driver : ${url}
db.properties中配置了url等jdbc连接属性: driver=org.sqlite.JDBCurl=jdbc:sqlite:D:/xxx/data/sqliteDB/demo.dbuse ...
- java.sql.SQLException: Io 异常: Connection reset
当数据库连接池中的连接被创建而长时间不使用的情况下,该连接会自动回收并失效,但客户端并不知道,在进行数据库操作时仍然使用的是无效的数据库连接,这样,就导致客户端程序报“ java.sql.SQLExc ...
随机推荐
- C#使用.net.mail配置163邮箱报错:不允许使用邮箱名称。 服务器响应为:authentication is required,smtp9,DcCowABHK4UYE11W2k6fAQ--.52196S2 1448940312
client.UseDefaultCredentials = true; 要放在 client.Credentials = new NetworkCredential("用户名", ...
- Linux企业级项目实践之网络爬虫(21)——扩展为多任务爬虫
高效的网络爬虫是搜索引擎的重要基础.采用多任务并发执行,实现类似于CPU的流水线(pipeline)运行方式,可极大地提高网络和计算资源的利用率等性能. #include "threads. ...
- Windows 8.1下使用IE 64位
Internet Options -> Advanced -> Settings Security组 对Enable 64-bit processes for Enhanced Prote ...
- maven compile时出现“非法字符: \65279”的解决
我碰到的这个问题是因为Java文件编码为UTF-8 BOM格式导致:解决这个可以使用UltraEdit. 用UltraEdit打开出问题的Java文件,将文件另存为,在保存对话框的编码中选择UTF-8 ...
- 面试题30.最小的k个数
题目:输入n个整数,找出其中最小的k个数,例如输入4,5,1,6,2,7,3,8 这8个数字,则最小的四个数字为1,2,3,4, 这道题是典型的TopK问题,剑指Offer提供了两种方法来实现,一种方 ...
- POJ1159 Palindrome(数位DP)
Palindrome Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 58277 Accepted: 20221 Desc ...
- adb网络调试
对Android比较熟悉的开发人员,对adb通过USB(USB连接Android设备)调试Android设备应该不会陌生,因为大部分资料都是这样做的.但是假如你的Android设备没有USB口,只有网 ...
- js高级程序设计(第三版)学习笔记(第一版)
ecma:欧洲计算机制造商协会iso/iec:国际标准化和国际电工委员会 dom级别(10*)文档对象模型1:DOM核心(映射基于xml文档)与dom html(在dom核心基础上)2:对鼠标,事件, ...
- python之模块:decimal
# -*- coding: utf-8 -*-__author__ = 'Administrator'#数学计算import decimal#用于定点和浮点运算#文档:https://docs.pyt ...
- px 和 em换算
常用px,pt,em换算表 pt (point,磅):是一个物理长度单位,指的是72分之一英寸. px (pixel,像素):是一个虚拟长度单位,是计算机系统的数字化图像长度单位,如果px要换算成物理 ...