錯誤描述:
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"