关于No ManagedConnections available within configured blocking timeout异常的解决
最近由于系统和业务重构需要,需要把线上1亿数据迁移到新库,由于业务变更,新表老表结构有变化,没法直接用dba dump的方式,需要自己写转换程序迁移。今天在调试的时候,碰到一个蛋疼的问题,就是一开始查询数据都正常,但是查询几条后日志就会报超时错误,具体日志如下:
No ManagedConnections available within configured blocking timeout ( 5000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 5000 [ms] ))
搜了下这个错误,各种说法比较多,但是感觉都没说到点上,找DBA看了下,DBA直接表示这个库连接数一直吃紧,从这个错误看也是连接超时,本来以为就这么着了,但是调试了几次都是一开始正常,后来报异常,就感觉肯定还是代码有问题导致连接数吃紧,后来仔细看了下代码,发现是connection没有关闭...应该说是没有关闭全。把PrepareStatement和ResultSet关闭了,但是没把最重要的Connection关闭掉...关闭了Connection就正常了。
网上几个搜的结果太过于误导人,所以就记录一下,碰到这个错误,首先是确认自己代码是否有相关connection没关闭掉,基本都是没关闭connection导致的,最后再确认数据库连接数是不是真的吃紧。
如下代码仅供参考:
try{
conn = sourceDs.getConnection();
ps = conn.prepareStatement(selectTcBizOrder);
rs = ps.executeQuery();
if(rs.next()){
result.put("auction_id", rs.getLong("auction_id"));
result.put("logistics_status", rs.getInt("logistics_status"));
result.put("attributes", rs.getString("attributes"));
return result;
}else{
return null;
}
}catch(SQLException e){
LogFactory.getTaskLog().error("[select tc_biz_order SQLException], bizOrderId="+bizOrderId, e);
return null;
}catch(Exception e){
LogFactory.getTaskLog().error("[select tc_biz_order other Exception], bizOrderId="+bizOrderId, e);
return null;
}finally{
if(rs != null){
try{
rs.close();
}catch(SQLException e){
LogFactory.getTaskLog().error("[close ResultSet SQLException], bizOrderId="+bizOrderId, e);
}
}
if(ps != null){
try {
ps.close();
} catch (SQLException e) {
LogFactory.getTaskLog().error("[close PreparedStatement SQLException], bizOrderId="+bizOrderId, e);
}
}
if(conn != null){
try{
conn.close();
}catch(SQLException e){
LogFactory.getTaskLog().error("[close Connection SQLException], bizOrderId="+bizOrderId, e);
}
}
}
关于No ManagedConnections available within configured blocking timeout异常的解决的更多相关文章
- 【异常】No ManagedConnections available within configured blocking timeout
Caused by: org.jboss.util.NestedSQLException: No ManagedConnections available within configured bloc ...
- RocketMQ的invokeSync call timeout异常的解决办法
缘起 在RocketMQ客户端的DefaultMQPushConsumer的start方法被执行时,时不时会报出invokeSync call timeout异常,如下: Caused by: jav ...
- pip install 报SSL异常和timeout异常
在安装pip3 install virtualenv时报了SSL异常 如图 pip is configured with locations that require TLS/SSL, however ...
- 使用StackExchange.Redis客户端进行Redis访问出现的Timeout异常排查
问题产生 这两天业务系统在redis的使用过程中,当并行客户端数量达到200+之后,产生了大量timeout异常,典型的异常信息如下: Timeout performing HVALS Parser2 ...
- Nginx 504 Gateway Time-out分析及解决方法
一.场景还原php程序在执行抓取远程图片库并保存至本地服务器的时候,出现了“504 Gateway Time-out”错误提示. 问题定位:由于图片巨多,所以下载时间很长(10分钟以上),引起网关超时 ...
- indy9在程序关闭时出现terminate thread timeout的BUG解决办法
indy9在程序关闭时出现terminate thread timeout的BUG解决办法 INDY9线程有BUG,在退出程序的时候会报错:terminate thread timeout(终止线程超 ...
- 504 Gateway Timeout 异常
生产销售系统出现 504 Gateway Timeout 异常,其实就是服务器响应太慢导致nginx带来超时,先不说服务端慢的优化问题:只是单纯的解决504.到网上发现了一篇文章fix it Add ...
- redis-内存异常 Redis is configured to save RDB snapshots解决
连接reids获取数据时提示 Redis is configured to save RDB snapshots, but is currently not able to persist on di ...
- jquery.form.js不能解决连接超时(timeout)的解决方法
最近在使用jquery.form.js提交包含文件的表单时,碰到了一个问题:当碰上网速较慢时,而我们又设置了timeout时,例如: var options = { timeout: 3000 //限 ...
随机推荐
- python caffe 在师兄的代码上修改成自己风格的代码
首先,感谢师兄的帮助.师兄的代码封装成类,流畅精美,容易调试.我的代码是堆积成的,被师兄嘲笑说写脚本.好吧!我的代码只有我懂,哈哈! 希望以后代码能写得工整点.现在还是让我先懂.这里,我做了一个简单的 ...
- php 配置上传大文件
打开php.ini,首先找到file_uploads = on ;是否允许通过HTTP上传文件的开关.默认为ON即是开upload_tmp_dir ;文件上传至服务器上存储临时文件的地方,如果没指定就 ...
- 每天一个linux命令:【转载】cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. ...
- 51nod 1347 旋转字符串
S[0...n-1]是一个长度为n的字符串,定义旋转函数Left(S)=S[1…n-1]+S[0].比如S=”abcd”,Left(S)=”bcda”.一个串是对串当且仅当这个串长度为偶数,前半段和后 ...
- VBA遍历单元格
Sub test() Dim str Dim i, j i = j = ).UsedRange.Rows.Count ).UsedRange.Columns.Count ).Cells(r, c).V ...
- oracle之 11g RAC R2 体系结构---Grid
-- 查看cluster 所维护的资源列表,不包括 OHAS 栈的 daemon [root@node1 bin]# ./crsctl status resource -t-------------- ...
- oracle 之 控制oracle RAC 进行并行运算
RAC的一大优点就是可以跨节点进行并行计算,那么如何控制并行运算?这就是这篇文章要讨论的内容. 10 g 中: 合理设置跨节点并行,需要先设置一些参数:instance_groups:这个参数主要是设 ...
- nginx 域名跳转一例~~~(rewrite、proxy)
来自: http://storysky.blog.51cto.com/628458/486338/ 前几天搭了一个论坛服务器并放到了公司的局域网里面,论坛用的是9066端口并在路由器上面做了个端口转发 ...
- ***XX-net 和 proxyee-down
看连接吧,留着方便自己查看 https://github.com/XX-net/XX-Net https://github.com/monkeyWie/proxyee-down/blob/master ...
- 19.Selenium+Python生成测试报告
1.代码如下所示: from selenium import webdriver import unittest import HTMLTestRunner class BaiduSearch(uni ...