springboot連mysql報一個奇怪的錯誤
錯誤提示:
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is 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.
解決辦法;
在連線字串後面加上?serverTimezone=UTC
其中UTC是統一標準世界時間。
完整的連線字串示例:jdbc:mysql://localhost:3306/dwkj?serverTimezone=UTC
另一種選擇:jdbc:mysql://localhost:3306/dwkj?useUnicode=true&characterEncoding=UTF-8,這個是解決中文亂碼輸入問題
最好結合使用
jdbc:mysql://localhost:3306/dwkj?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8
其中UTC是統一標準世界時間。
完整的連線字串示例:jdbc:mysql://localhost:3306/dwkj?serverTimezone=UTC
另一種選擇:jdbc:mysql://localhost:3306/dwkj?useUnicode=true&characterEncoding=UTF-8,這個是解決中文亂碼輸入問題
最好結合使用
jdbc:mysql://localhost:3306/dwkj?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8