Connections could not be acquired from the underlying database!
Connections could not be acquired from the underlying database!
报错截图:
报错内容:
Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at com.courage.pool.c3p0.C3P0Test.main(C3P0Test.java:38)
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1469)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
报错原因:
参考链接:MySQL JDBC Driver 5.1.33 - Time Zone Issue
MySQL JDBC驱动程序的5.1.33后面的版与UTC时区一起使用,必须serverTimezone
在连接字符串中显式指定。
解决办法:
在url后面加上时区信息:
jdbc:mysql://localhost:3306/jdbc?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC