Tomcat hangs if C3P0 can't get a database connection
2013-08-30 15:18
465 查看
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:
acquireRetryAttemptsacquireRetryDelay
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
相关文章推荐
- org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool er
- spring--data-mongondb ...CannotGetMongoDbConnectionException: Failed to authenticate to database
- After restoring database in SQL Server, if you can't use diagram, execute these sentences
- org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting
- [Tomcat]Cannot get a connection, pool exhausted
- Can't allocate space for object 'syslogs' in database 'ge' because 'logsegment' segment is full/has no free extents. If you ran
- BUG记录之 Database Connection Can’t Be Open!
- rabbitmq 集群 ha负载 Consumer raised exception, processing can restart if the connection factory
- Get Database Connection from Web Application Server Data Source
- FAQ(33):Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
- How can I get my public IP address from the command line, if I am behind a router?
- org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting
- tomcat 连接池泄露的问题:org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause:java.util.NoSuchEleme
- tomcat:Cannot get a connection, pool exhausted
- Database Connection Pooling with Tomcat
- org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object异常原因
- Could not get JDBC Connection; nested exception is org.apache.tomcat.jdbc.pool.PoolExhaustedExceptio
- SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called t
- If Miami's Big Three can get the championship
- 关于wifiManager.getConnectionInfo()与wifiManager.getScanResults()的使用问题