C3p0 exceptions and Solutions

Source: Internet
Author: User

When the concurrency is large, the c3p0 connection pool displays the following exception:

Caused by: Java. SQL. sqlexception: an attempt by a client to checkout a connection has timed out. at COM. mchange. v2. SQL. sqlutils. tosqlexception (sqlutils. java: 106) at com. mchange. v2. SQL. sqlutils. tosqlexception (sqlutils. java: 65) at com. mchange. v2.c3p0. impl. c3p0pooledconnectionpool. checkoutpooledconnection (c3p0pooledconnectionpool. java: 527) at com. mchange. v2.c3p0. impl. abstractpoolbackeddatasource. getconnection (abstractpoolbackeddatasource. java: 128) at Org. springframework. JDBC. datasource. datasourceutils. dogetconnection (performanceutils. java: 113) at Org. springframework. JDBC. datasource. datasourceutils. getconnection (performanceutils. java: 79 )... 5 morecaused by: COM. mchange. v2.resourcepool. timeoutexception: a client timed out while waiting to acquire a resource from -- timeout at awaitavailable () at com. mchange. v2.resourcepool. basicresourcepool. awaitavailable (basicresourcepool. java: 1317) at com. mchange. v2.resourcepool. basicresourcepool. prelimcheckoutresource (basicresourcepool. java: 557) at com. mchange. v2.resourcepool. basicresourcepool. checkoutresource (basicresourcepool. java: 477) at com. mchange. v2.c3p0. impl. c3p0pooledconnectionpool. checkoutpooledconnection (c3p0pooledconnectionpool. java: 525 )... 8 more

The exception analysis for this part is as follows:

On the Internet, it is often said that c3p0 has a bug. When c3p0 closes both statement and connection, or closes them for a short time, sometimes the connection is not closed because some preparedstatement is still in cached state. In this way, many connections are not actually closed, and the connection pool is exhausted, the above exception will occur. The solution is to disable the cache, that is, to disable c3p0. max_statements is set to 0, so that no cached preparedstatement exists, and c3p0 is set. idle_test_period is smaller than c3p0. timeout.

If you have time to look back, read the source code study. Now, we can solve this problem first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.