Tomcat hangs if C3P0 can't get a database connection
来源:互联网 发布:java安全级别没有中 编辑:程序博客网 时间:2024/06/06 02:03
c3p0 DataSources are designed (and configured by default) to recover from temporary database outages, such as those which occur during a database restart or brief loss of network connectivity. You can affect how c3p0 handles errors in acquiring Connections via the following configurable properties:
- acquireRetryAttempts
- acquireRetryDelay
- breakAfterAcquireFailure
When a c3p0 DataSource attempts and fails to acquire a Connection, it will retry up to acquireRetryAttempts times, with a delay of acquireRetryDelay between each attempt. If all attempts fail, any clients waiting for Connections from the DataSource will see an Exception, indicating that a Connection could not be acquired. Note that clients do not see any Exception until a full round of attempts fail, which may be some time after the initial Connection attempt. If acquireRetryAttempts is set to 0, c3p0 will attempt to acquire new Connections indefinitely, and calls to getConnection() may block indefinitely waiting for a successful acquisition.
Once a full round of acquisition attempts fails, there are two possible policies. By default, the c3p0 DataSource will remain active, and will try again to acquire Connections in response to future requests for Connections. If you set breakAfterAcquireFailure to true, the DataSource will consider itself broken after a failed round of Connection attempts, and future client requests will fail immediately.
Note that if a database restart occurs, a pool may contain previously acquired but now stale Connections. By default, these stale Connections will only be detected and purged lazily, when an application attempts to use them, and sees an Exception. Setting maxIdleTime or maxConnectionAge can help speed up the replacement of broken Connections. (See Managing ConnectionAge.) If you wish to avoid application Exceptions entirely, you must adopt a connection testing strategy that is likely to detect stale Connections prior to their delivery to clients. (See "Configuring Connection Testing".) Even with active Connection testing (testConnectionsOnCheckout set to true, or testConnectionsOnCheckin and a short idleConnectionTestPeriod), your application may see occasional Exceptions on database restart, for example if the restart occurs after a Connection to the database has already been checked out.
参考来源:http://www.mchange.com/projects/c3p0/#configuring_recovery
- Tomcat hangs if C3P0 can't get a database connection
- c3p0 You can't operate on a closed Connection解决办法
- [Tomcat]Cannot get a connection, pool exhausted
- Can't open a connection to site 'SYB_BACKUP' 解决办法
- can't open a connection to site 'syb_backup' 解决
- 解决can't open a connection to site 'syb_backup'
- You can't operate on a closed Connection!!!
- the database principal owns a service in the database -- can't drop a user
- After restoring database in SQL Server, if you can't use diagram, execute these sentences
- Couldn't get connection because we are at maximum connection count (10/10) a
- Database Connection Pooling with Tomcat
- Error establishing a database connection!
- Setting up a Database Connection
- Can't get kernel image!
- Inspect can't get element
- glfw can't get window
- Can't get the locations
- Zynq --can't get kernel
- Java中synchronized注意点
- C#用递归求阶乘 n!
- WaitForSingleObject的用法
- MySQL性能优化的最佳20+条经验
- A20 GPIO中断类型差别结果迥异的问题思考
- Tomcat hangs if C3P0 can't get a database connection
- 在两个Android设备间通过UDP传输目录内文件
- Struts2的配置文件基础
- linux和vs中 qt程序中文国际化
- 奈奎斯特定理和香农定理
- 思维导图之于用人策略
- java UI皮肤
- MongoDB介绍及安装(1)
- SecureCRT连linux经常断线解决办法