【错误处理】【MySQL】The server time zone value '' is unrecognized or represents more than one time zone.

错误描述:

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参数。

  1. 如果该参数是’?'后的第一个,应写为
    url = "jdbc:mysql://127.0.0.1:3306/database_name?serverTimezone=UTC"
  2. 如果该参数不是’?'后的第一个,应写为
    url = "jdbc:mysql://127.0.0.1:3306/database_name?characterEncoding=utf8;serverTimezone=UTC"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章