错误描述:
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.
解决办法:
在数据库驱动的url后加上serverTimezone=UTC
参数。
- 如果该参数是’?'后的第一个,应写为
url = "jdbc:mysql://127.0.0.1:3306/database_name?serverTimezone=UTC"
- 如果该参数不是’?'后的第一个,应写为
url = "jdbc:mysql://127.0.0.1:3306/database_name?characterEncoding=utf8;serverTimezone=UTC"