使用連接mysql的jdbc驅動最新版引發的問題

使用最新的連接驅動 

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>6.0.3</version>
    </dependency>

運行程序時拋出異常:

Caused by: 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.

解決辦法:

jdbcUrl=jdbc:mysql://localhost:3306/spring

後面加上:

jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC  

但如果你的jdbcUrl類似下面:

jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC&characterEncoding=utf-8

就是有多個params的時候需要以&分開,但&要改爲&amp;  如下:

jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC&amp;characterEncoding=utf-8

 

發佈了83 篇原創文章 · 獲贊 3 · 訪問量 4572
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章