Today, when looking at the c3p0 connection pool, a crazy error was reported because of the connection to the database
com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@1c83354 -- timeout at awaitAvailable()
Finally, I checked Baidu, Google, etc., and found that Google is really easy to use! ! !
Finally found the solution as follows:
<?xml version="1.0" encoding="utf-8"?>
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/shopping?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC</property>
<property name="user">root</property>
<property name="password">123456</property>
<property name="initialPoolSize">5</property>
<property name="maxPoolSize">240</property>
<property name="checkoutTimeout">60000</property>
<property name="acquireIncrement">1</property>
</default-config>
</c3p0-config>
The checkoutTimeout property is still not big enough when configuring, causing the connection pool to automatically pause before it gets the connection.
Change the value of this attribute from 3000 to 60000.