简体   繁体   中英

Tomcat hangs if C3P0 can't get a database connection

I've an application that uses Spring+Hibernate+C3P0 as the connection pool. If I start the application and the database is down, Tomcat hangs for a long log time withouth giving any feedback. Is there some property that I can set to avoid this? For example, if after 30 seconds it can't get a connection, throw a connection timeout exception.

By default, it should take about 30 seconds before c3p0 signals a failure if it cannot acquire a Connection. You can control the length of time by modifying either the number of attempts c3p0 makes at the database or the interval between attempts.

See c3p0.acquireRetryAttempts and c3p0.acquireRetryDelay .

If you set c3p0.acquireRetryAttempts to one, c3p0 won't retry and connection attempts will fail retry immediately.

See also Configuring Recovery From Database Outages .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM