错误原因:
1、Exception in thread "main" java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
2、Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@66048bfd -- timeout at awaitAvailable()
按照字面意思就是,连接超时。因为是用的c3p0连接池。所以只能在 c3p0-config.xml 中去寻找错误。 配置文件如下:
解决办法:
mysql8.0之后的版本,除了导包之外,还要记得改xml文件
如下:
1.driverClass 8.0和5.0不一样,有个cj
2.jdbcUrl,除了要改成自己的数据库名外,mysql8.0还要加上时区,即serverTimezone=GMT
<!-- 连接参数 -->
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/gyp2021?serverTimezone=GMT</property>
<property name="user">root</property>
<property name="password">123456</property>
标签:cj,resourcepool,jar,C3P0,mysql,com,连接池,out
From: https://blog.csdn.net/weixin_66383346/article/details/137609219