The server time zone value 'Öйú±ê׼ʱ¼ü'is unrecognized or represents more than one time zone問題解決

3482 ワード

今日、JDBCを使用してデータベースに接続する際に問題が発生しました.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
(これは主なものではありません.現在最新のmysql-connector-java-8.0.9-rc.jarのMySQLドライバパッケージを使用しているので、新しいドライバパッケージでは`com.mysql.jdbc.Driver'クラスは古くなり、新しい`com.mysql.cj.jdbc.Driver'はSPIで自動的に登録され、手動でドライバクラスをロードする必要はありません)
Sat Apr 14 14:18:21 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
(これも主なことではありません:サーバ認証なしでSSL接続を確立することは推奨されません.MySQL 5.5.45+、5.6.26+、5.7.6+の要件に従って、明示的なオプションを設定しない場合は、デフォルトのSSL接続を確立する必要があります.SSLを使用しない既存のアプリケーション・シーケンスと互換性を持つためにverifyServer Certificateプロパティは「false」に設定されます..useSSL=falseを設定してSSLを明示的に無効にするか、useSSL=trueを設定してサーバ証明書の検証に信頼できるストレージを提供する必要があります.)
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.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:874)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:234)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:227)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.mytestings.mysql.MySQLDemo.main(MySQLDemo.java:23)
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: 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.
上の赤いSQL異常です.データベースURLにserverTimezoneプロパティを設定する必要があります.
static final String DB_URL = "jdbc:mysql://localhost:3306/RUNOOB" +
        "?serverTimezone=GMT%2B8";
ここの
GMT%2B8 
代表は東八区です.