使用JDBC连接MySql数据库,启动测试类报错,错误信息:
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.
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
分析得到解决办法:
在连接数据库的URL后面加上?serverTimezone=UTC
UTC是统一的标准世界时间
jdbc:mysql://localhost:3306/test?serverTimezone=UTC