`
MauerSu
  • 浏览: 513715 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

c3p0数据库连接池不能取到连接An attempt by a client to checkout a Connection has timed out

 
阅读更多
源:https://blog.csdn.net/attilax/article/details/17770113
评:
paip.提升稳定性---c3p0数据库连接池不能取到连接An attempt by a client to checkout a Connection has timed out

作者Attilax  艾龙,  EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax

最开始,卡死,不动了,,使用jprofile, thread dump...原来是在getconn()在wait..默认

添加设置
# 当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出   
# SQLException,如设为0则无限期等待。单位毫秒,默认为0
c3p0.checkoutTimeout=10000

此时,取得conn不到报错。c3p0连接错误 An attempt by a client to checkout a Connection has timed out


----根本原因: 池中的连接已经被全部使用完了..达到了最大maxconn...从而导治这个错误...

----其他原因:忘记close conn,或者异常了而没有close conn,没有释放conn从池中。。...导治池中的conn满的了...


、、、、、解决方法: 
a.适当加大maxPoolSize和minPoolSize  ,可以大大缓解这种情况。。
c3p0.maxPoolSize=5000
c3p0.minPoolSize=10

b.检测代码 close conn..释放conn...当然这个总是有遗漏.最小化这个影响就好..

c.自动超时回收Connection (强烈推荐)
c3p0.unreturnedConnectionTimeout=25
default : 0 单位 s
为0的时候要求所有的Connection在应用程序中必须关闭。如果不为0,则强制在设定的时间到达后回收
Connection,所以必须小心设置,保证在回收之前所有数据库操作都能够完成。这种限制减少Connection未关闭
情况的不是很适用。为0不对connection进行回收,即使它并没有关闭。

d.配置超时自动断开conn (推荐)
c3p0.maxIdleTimeExcessConnections=20
c3p0.maxConnectionAge=20
default : 0 单位 s
配置连接的生存时间,超过这个时间的连接将由连接池自动断开丢弃掉。当然正在使用的连接不会马上断开,而是等待
它close再断开。配置为0的时候则不会对连接的生存时间进行限制。



e.最后,show full processlist  ..查看db conn数,,稳定后走ok...否则适当调整以上参数..


------------还有一种说法。c3p0.max_statements 设置成0 可以解决。时间忙,没有验证。。。

网上很多说是C3P0的bug问题。c3p0在同时关闭statement和connection的时候,或者关闭他们之间的时间很短的时候,有时候connection并没有被关闭,因为有些preparedstatement还在被cached住。这样就会有很多connection并没有真正的被关闭,连接池的连接都给耗尽了,就会产生上面的异常。解决的方案就是把缓存关闭也就是把c3p0.max_statements 设置成0,这样就不会有缓存的preparedstatement,而设置的c3p0.idle_test_period又小于c3p0.timeout,这样的设置应该没有什么问题了。
分享到:
评论

相关推荐

    c3p0数据库连接

    DataSourceUtils.java c3p0数据库连接

    mysql密码过期导致连接不上mysql

    mysql密码过期了,今天遇到了连接mysql,总是连接不上去, 错误现象1: An attempt by a client to checkout a Connection has timed out 第一次出现连接超时错误,第一反应是去修改cpool.checkoutTimeout参数为...

    DB2数据库跨平台备份与恢复

    SQL2570N 错误的全称是“An attempt to restore on target OS from a backup created on source OS failed due to the incompatibility of operating systems or an incorrect specification of the restore command...

    orcad15.7 破解方法

    orcad15.7 安装问题解决:An application has made an attempt to load the C runtime library incorrectly. Please ccontact the application"s support team for more information!

    【ASP.NET编程知识】.net core并发下线程安全问题详解.docx

    异常5“Object reference not set to an instance of an object”是经典的空引用异常,意味着尝试访问的对象尚未初始化。这可能由于代码中的null检查不足导致,需要在访问对象属性或方法前确保对象已被正确实例化。 ...

    计算机网络第六版答案

    Hence, it becomes possible for the attacker to issue a command to all the nodes, that target a single node (for example, all nodes in the botnet might be commanded by the attacker to send a TCP SYN ...

    An attempt to read, understand, and implement the AUTOSAR SWS Po

    An attempt to read, understand, and implement the AUTOSAR SWS Port Driver according to the specification in a demo full-layered AUTOSAR a…

    Linux中无法远程连接数据库问题的解决方法

    Your connection attempt failed for user 'root' from your host to server at 118.89.153.162:3306: Access denied for user 'root'@'118.89.153.162' (using password: YES) 思路 网络问题,更换网络之后重启...

    VB编程资源大全(英文源码 数据库)

    By supplying a DSN entry, it will attempt to connect to that database and list all the tables in it. When you click on a table, it lists all <END><br>38,3a.zip An Inventory System, you can add, ...

    Kerberos Administration Guide

    The Kerberos protocol uses strong cryptography so that a client can prove its identity to a server (and vice versa) across an insecure network connection. After a client and server has used Kerberos ...

    An attempt at a C++ tutorial..zip

    总的来说,"An attempt at a C++ tutorial"可能涵盖了以上提到的所有或部分主题,旨在为初学者提供一个全面的C++学习路径。通过逐步学习并实践这些概念,你可以逐渐精通C++,并能够编写出高质量的代码。

    BURNINTEST--硬件检测工具

    - Updated license management, in an attempt to remove a rare crash on startup. Release 5.3 build 1012.0002 WIN32 release 31 October 2007 - New build of Rebooter (64-bit Windows correction). - ...

    微软内部资料-SQL性能优化3

    For example, suppose a transaction scanned a page using an S lock and then subsequently decided to perform a row level update. The row would obtain an X lock, but now the page would require an IX ...

    A Practical Guide to Designing with Data.pdf

    new ʻvisualizationsʼ are an attempt to explain the underlying information with a powerful visual impact. They take complex ideas and distil them into beautiful graphics revealing the ...

    windows蓝屏错误代码

    130 0×00000082 Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O. 131 0×00000083 尝试将档案指针移至档案开头之前。 132 0×00000084 无法在指定的装置或档案...

    2009 达内Unix学习笔记

    一行不能超过256个字符;大小写有区分。 二、特殊字符含义 文件名以“.”开头的都是隐藏文件/目录,只需在文件/目录名前加“.”就可隐藏它。 ~/ 表示主目录。 ./ 当前目录(一个点)。 ../ 上一级目录(两个...

    Programmable Logic Controllers A Practical Approach TO IEC 61131-3 Using CoDeSys

    This development was the natural result of the attempt by the producers to make themselves stand out among increasing competition by developing the most user friendlylanguages and tools.

Global site tag (gtag.js) - Google Analytics