MySQL—JDBCにThe server time zone value'???ú±ê×??±??' is unrecognized or represents more...のエラーメッセージ

984 ワード

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.
エラーメッセージ翻訳——java.sql.SQLException:サーバータイムゾーン値'?u±e×??±??複数のタイムゾーンが認識されていないか、または代表されていない.タイムゾーンサポートを使用する場合は、サーバまたはJDBCドライバ(serverTimezoneによるプロパティの構成)を構成して、より特殊なタイムゾーン値を使用する必要があります.
解決方法:JDBC接続のURLにserverTimezone=GMTを付け、GMT+8タイムゾーンを使う必要がある場合はGMT%2 B 8と書く必要があります.
変更前のコード:
private static String dbUrl = "jdbc:mysql://localhost:3306/db_shop?characterEncoding=utf8&useSSL=false";

変更後のコード:
private static String dbUrl = "jdbc:mysql://localhost:3306/db_shop?characterEncoding=utf8&useSSL=false&serverTimezone = GMT";

このとき,エラーは解決される.