警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@2a770744 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
时间: 2024-04-28 12:20:43 浏览: 321
c3p0连接池常用jar(c3p0.jar和mchange-commons-java-.jar)
这个警告信息表明,您的Java应用程序使用c3p0连接池向MySQL数据库请求连接时,连接池尝试30次获取新连接时失败了。最后的尝试异常是“java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.”
这个异常是由于MySQL数据库和JDBC驱动程序之间的时区不一致导致的。为了解决这个问题,您可以通过以下方式之一:
1. 在连接MySQL数据库时,指定正确的时区。例如,使用JDBC URL连接字符串,加上serverTimezone参数,指定正确的时区,例如:
jdbc:mysql://localhost:3306/mydatabase?serverTimezone=UTC
2. 在MySQL服务器上设置正确的默认时区。例如,使用以下命令将默认时区设置为UTC:
SET GLOBAL time_zone = '+00:00';
3. 在JDBC驱动程序中设置时区。例如,在应用程序中添加以下代码:
TimeZone timeZone = TimeZone.getTimeZone("UTC");
TimeZone.setDefault(timeZone);
希望这些解决方案能够帮助您解决问题。
阅读全文