相信很多小伙伴和我一样遇到了这类问题,在使用JDBC连接mysql数据库的时候发生SQLException如下所示的异常情况!

  1. 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.
  2. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
  3. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
  4. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
  5. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
  6. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
  7. at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:)
  8. at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:)
  9. at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:)
  10. at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:)
  11. at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:)
  12. at java.sql.DriverManager.getConnection(Unknown Source)
  13. at java.sql.DriverManager.getConnection(Unknown Source)
  14. at com.ast.service.impl.VboxDataServiceImpl.insertAll(VboxDataServiceImpl.java:)
  15. at com.ast.controller.Thread_send.run(Thread_send.java:)
  16. Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
  17. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  18. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  19. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  20. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  21. at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:)
  22. at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:)
  23. at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:)
  24. at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:)
  25. at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:)
  26. at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:)
  27. at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:)
  28. at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:)
  29. ... more

这其实是由于在安装的时候没有选择使用位置,mysql默认使用美国时间,所以得改成我们东八区的时间。

所以应该怎么做呢?

首先网上有很多方法是更改数据库中的 time_zone,如下图:

这个方法只能是解决这一次问题,重启之后依然会报错,还需要再次更改。

最好的方法就是在jdbc配置中添加?serverTimezone=UTC到末尾。

如下图所示:

对于使用JDBC连接mysql数据时The server time zone value '¤¤°ê¼Ð·Ç®É¶¡'...的异常问题解决。的更多相关文章

  1. 解决使用DBeaver连接MySQL时报错-The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.

    解决使用DBeaver连接MySQL时报错,其实提示很明显. The server time zone value '�й���׼ʱ��' is unrecognized or represents ...

  2. 连接mysql报错 : The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone...

    time zone 时区错误 DBEAVER连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or repres ...

  3. 关于jdbc连接MySQL数据问题

    1.解压MySQL后配置环境变量 MYSQL_HOME:D:\win7\Program Files(x86)\mysql-5.6.21-win32(mysql根目录) 添加path:%MYSQL_HO ...

  4. 连接MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

    MySQL time zone 时区错误 使用root用户登陆执行命令: ---> show variables like '%time_zone%'; 默认值system为美国时间:如下图: ...

  5. JDBC连接MySQL数据库及演示样例

    JDBC是Sun公司制定的一个能够用Java语言连接数据库的技术. 一.JDBC基础知识         JDBC(Java Data Base Connectivity,java数据库连接)是一种用 ...

  6. JDBC连接MySQL数据库及示例

      JDBC是Sun公司制定的一个可以用Java语言连接数据库的技术. 一.JDBC基础知识         JDBC(Java Data Base Connectivity,java数据库连接)是一 ...

  7. JDBC连接MySQL数据库基础

    主要内容 MySQL的基本操作和基本SQL语法 使用JDBC进行MySQL数据库的开发 使用DriverManager.Connection.PreparedStatement.ResultSet对数 ...

  8. 分页查询信息(使用jdbc连接mysql数据库实现分页查询任务)

             分页查询信息       使用jdbc连接mysql数据库实现分页查询任务 通过mysql数据库提供的分页机制,实现商品信息的分页查询功能,将查询到的信息显示到jsp页面上. 本项目 ...

  9. 修改sqlarchemy源码使其支持jdbc连接mysql

    注意:本文不会将所有完整源码贴出,只是将具体的思路以及部分源码贴出,需要感兴趣的读者自己实验然后实现吆. 缘起 公司最近的项目需要将之前的部分业务的数据库连接方式改为jdbc,但由于之前的项目都使用s ...

随机推荐

  1. React文档(十七)非受控组件

    大多数情况下,我们建议使用受控组件(也就是用React的state来控制表单元素的value值)来实现表单.在一个受控组件里,表单数据被React组件处理.另一种方案就是非控制组件,这样的话表单数据就 ...

  2. Centos 7 搭建DNS笔记

    bindind的程序包 bind-libs:被bind和bind-utils包中的程序共同用到的库文件: bind-utils:bind客户端程序集:提供了,dig , host, nslookup等 ...

  3. 使用Python-Libvirt GUI 实现KVM 虚拟机 界面化管理

    一.KVM环境的搭建 1.安装VMware(略) 2.在VMware中安装Linux系统(略,Ubuntu16.04) 打开支持虚拟化 网络选择桥接模式 3.安装qemu apt-get instal ...

  4. ceph crush的问题

    ceph crush的问题看一遍忘一遍,现将<ceph源码分析>一书中相关章节摘抄如下: 4.2.1 层级化的Cluster Map例4-1 Cluster Map定义层级化的Cluste ...

  5. Android 音视频深入 十三 OpenSL ES 制作音乐播放器,能暂停和调整音量(附源码下载)

    项目地址https://github.com/979451341/OpenSLAudio OpenSL ES 是基于NDK也就是c语言的底层开发音频的公开API,通过使用它能够做到标准化, 高性能,低 ...

  6. Android7.0手机程序保活(附源码下载)

    项目地址,求starhttps://github.com/979451341/AppAlive 本人在学习音视频时无意发现的黑科技,发现在使用AudioTrack播放音乐时,使用手机的一键清理发现程序 ...

  7. .net core webapi带权限的文件下载方法

    众所周知,在webapi中,如果有个接口需要权限,一般会将带权限的字段塞进header中.但是,在带权限的文档下载接口中,无论是用post,还是get方式,我们无法设置header头信息.苦恼呀?别急 ...

  8. java类的高级概念

  9. oh_my_zsh

    oh_my_zsh  zsh默认已经安装   cat /etc/shells   查看安装没有   (https://xiaozhou.net/learn-the-command-line-iterm ...

  10. 判断手机是安卓还是ios

    let ORZ = function() { if(!(this instanceof ORZ)) { return new ORZ; }}ORZ.prototype = { // 判断用户手机是An ...