报错解决:时区设置错误-The server time zone value ‘�й���‘ is unrecognized or represents more than one time zone

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

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.

报错解决:时区错误,将代码改成如下即可:

原代码:

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?" +
                "useUnicode=true&characterEncoding=utf-8", "root", "1234");

改成这样:

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?" +
                "characterEncoding=utf-8&serverTimezone=UTC", "root", "1234");

参考链接

猜你喜欢

转载自blog.csdn.net/qq_38960155/article/details/109720265