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'

  • 相关阅读:
    centOS7 查看防火墙状态 开放端口
    PHP之Trait详解 转
    ps 树形显示
    composer 打印美化
    第一章 Java Web应用开发技术
    团队博客20
    团队博客19
    团队博客18
    团队博客17
    团队博客16
  • 原文地址:https://www.cnblogs.com/xjs1874704478/p/13640346.html
Copyright © 2011-2022 走看看