JDBCの2つの小さな問題

1010 ワード

  • The Server time zone value'XXXXX'文字化けし--MySQLデータベース接続エラー
  • エラーメッセージ:
    mysql java.sql.SQLException: The server time zone value‘XXXXXX' is unrecognized or represents...
    

    理由:
                      
    

    ソリューション:1. jdbc url serverTimezone=GMT , gmt+8 , GMT%2B8, 。 2. MySQL jdbc ,5.1.28 。 : url=jdbc:mysql://localhost:3306/test?useUnicode=true$characterEncoding=utf8
    に改心url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC
  • 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.
    理由:

    解決策:
    com.mysql.jdbc.Driverをcomに変更します.mysql.cj.jdbc.Driverでいいです.