zoukankan      html  css  js  c++  java
  • java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä'...解决

    在使用idea连接mysql测试时,报的错:

    Cause: 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.

    这是在使用MySQL8.0以上的版本的时候出现的错误,我们需要在访问数据库的URL后面追加一下参数即可:

    ?serverTimezone=GMT%2B8

     比如:我pom.xml文件中的依赖为:

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

    我的URL为:

    jdbc:mysql://localhost:3306/xjs

    应该修改为:

    jdbc:mysql://localhost:3306/xjs?serverTimezone=GMT%2B8

    从错误上看应该是时区的错误,这里的GMT%2B8代表东八区。

    还有一种解决方法就是设置整个数据库的时区,可以执行下面的语句来完成:

    1.show variables like '%time_zone%'

    2.set global time_zone='+8:00'

  • 相关阅读:
    scrapy(二)内容获取
    scrapy(一)建立一个scrapy项目
    scrapy(四)使用redis
    scrapy(三)使用mongoDB
    索引处的解码字符串
    Golang竞争状态
    Golang之泛型编程-细节
    区块链学这个就够了-DLT(一)
    Linux日志分析-Ubuntu(一)
    经典博弈-int
  • 原文地址:https://www.cnblogs.com/xjs1874704478/p/13640346.html
Copyright © 2011-2022 走看看