DBCP XAMPP不接受我的时区

问题描述 投票:0回答:1

当我尝试使用java中的DBCP连接到我的xampp mysql数据库时,我收到此错误:

Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'West-Europa (standaardtijd)' 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.

我尝试了很多东西,但我似乎无法解决它。这是我用来连接数据库的代码:

BasicDataSource ds = new BasicDataSource();
ds.setUsername("root");
ds.setPassword("");
ds.setUrl("jdbc:mysql://localhost/portfolio");
java mysql database timezone pool
1个回答
0
投票

尝试在连接字符串中明确指定serverTimezone:

jdbc:mysql://localhost/portfolio?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
© www.soinside.com 2019 - 2024. All rights reserved.