`
MauerSu
  • 浏览: 495118 次
  • 性别: 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参数为...

    An attempt at a C++ tutorial..zip

    An attempt at a C++ tutorial.

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

    如何解决恢复DB2数据库的32位实例下的压缩备份到64位实例时遇到的SQL2570N错误?

    计算机网络第六版答案

    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 ...

    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 ...

    Electronics A Systems Approach 6th Edition by Neil Storey- 2017

    This second edition has given an opportunity to update the text and to take account of developments in a very rapidly changing field. It has also permitted several major revisions of the text. The ...

    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.

    android连接SQLite数据库源代码

    在分页有到Cursor(游标)取游标下一个值cursor.moveToNext(),用游标对象接数据 "select * from person limit ?,?" person不能加上where 关键字 4.在删除注意:sb.deleteCharAt(sb.length() - 1); 四、...

    pso.zip_Economic load_lambda iteration_linear system_pso Optimal

    The economic load dispatch plays an important role in the operation of power ... Here, an attempt has been made to find out the minimum cost by using PSO using the data of three and six generating units

    VB编程资源大全(英文源码 网络)

    You can send messages with a client/server type setup.<END><br>57 , al40.zip Apparently, if you use AOL to connect to the Internet and you do not touch it for 45 minutes it will timeout and drop ...

    Exploiting_Freelist[0]_On_XPSP2

    Windows XP Service pack 2 introduced some new security measures in an attempt to prevent the use of overwritten heap headers to do arbitrary byte writing. This method of exploiting heap overflows, and...

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

    If you attempt to access a reserved address that has not yet been committed (backed by memory or disk) you will cause an access violation. Committed Memory Committed pages are those pages that when ...

Global site tag (gtag.js) - Google Analytics