1. 程式人生 > >JDBC連線MySql,配置url報錯 使用JDBC連線MySql時出現:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must co

JDBC連線MySql,配置url報錯 使用JDBC連線MySql時出現:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must co

 

使用JDBC連線MySql時出現: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

在連線字串後面加上?serverTimezone=UTC

其中UTC是統一標準世界時間。

完整的連線字串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC

或者還有另一種選擇:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,這個是解決中文亂碼輸入問題,當然也可以和上面的一起結合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

在連線字串後面加上?serverTimezone=UTC

其中UTC是統一標準世界時間。

完整的連線字串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC

或者還有另一種選擇:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,這個是解決中文亂碼輸入問題,當然也可以和上面的一起結合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC