zoukankan      html  css  js  c++  java
  • 使用高版本mysql-connector-java的时区问题

    错误信息

    今天在复习 JavaEE 相关内容的时候,遇到报错

    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.

    然后发现他的driver也改成com.mysql.cj.jdbc.Driver
    

    原因

    ​ 驱动包版本:mysql-connector-java-8.0.18.jar

    ​ 后来在查资料后发现数据库安装时默认为英语,是0:00时区,但是用以前旧版本的MySql jdbc 驱动都不会让你设置时区,新版就需要了。。。。

    解决方法

    将连接数据库的url加上,UTC(世界均衡时间)参数,或者GMT(格林尼治时间),如下:

    jdbc:mysql://localhost:3306/demo?serverTimezone=UTC
    jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=UTC
    jdbc:mysql://localhost:3306/demo?serverTimezone=GMT
    jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT
    

    不过后来测试发现,这个时间比北京时间早8个小时,所以使用北京时间如下:

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

    更多内容大家可以访问我的个人博客:一只大大怪

  • 相关阅读:
    模拟ajax请求爬取微博
    使用nohup+& 踩到的坑
    Python3爬虫一之(urllib库)
    在linux下安装并运行scrapyd
    创建Django项目并将其部署在腾讯云上
    python解析库之 XPath
    python3中urllib库的request模块详解
    HTTP协议详解
    线程之红绿灯
    win7 64 下安装MyGeneration 遇到的问题解决方法
  • 原文地址:https://www.cnblogs.com/cydi/p/12573638.html
Copyright © 2011-2022 走看看