在使用JDBC连接MySql时报错: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.

具体报错如下:

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.
在这里说一下为什么会出现这样的问题,因为我创建的是springboot项目,在pom中添加mysql依赖,并没有设置版本号,因为springboot内部配置过了。它配置的版本号是8.0.13  就是因为mysql的版本太高了,所以才会出现这个报错。

如果你加载mysql比较低的版本,则不会有这种情况了。

解决方法:
在配置文件中的 连接字符串后面加上?serverTimezone=UTC

UTC是统一标准世界时间

完整的连接字符串示例:jdbc:mysql://localhost:3306/hello?serverTimezone=UTC

如果指定使用gmt+8时区,需要写成GMT%2B8,否则可能报解析为空的错误

顺便一提,如果输入中文存在乱码,可以如下设置:

jdbc:mysql://127.0.0.1:3306/hello?useUnicode=true&characterEncoding=UTF-8

当然,为了稳妥,你也可以都写上 如下:

jdbc:mysql://127.0.0.1:3306/hello?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

搞定。
---------------------
作者:weixin_42652696
来源:CSDN
原文:https://blog.csdn.net/weixin_42652696/article/details/83864740
版权声明:本文为博主原创文章,转载请附上博文链接!

【转载】在使用JDBC连接MySql时报错: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的更多相关文章

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

    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha ...

  3. 三、SpringBoot启动时JDBC报错:You must configure either the server or JDBC driver (via the serverTimezone configuration property)

    错误提示: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connectio ...

  4. You must configure either the server or JDBC driver (via the serverTimezone configuration property

    使用JDBC连接MySql时出现:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one ...

  5. Android jdbc连接mysql报错解决方案 (Communications link failure)

    最近调试安卓连接mysql真是心态爆炸,快两天才搞出来.以下整理一些常见问题. 检查manifest文件里网络权限是否打开 检查数据库IP是否有问题(包括一些沙雕错误,比如是不是在ip首或尾多了个空格 ...

  6. python MySQLdb连接mysql时报错

    故障现象: >>> import MySQLdb >>> conn = MySQLdb.connect(host=,charset="utf8" ...

  7. 使用navicat连接mysql时报错:2059 - authentication plugin 'caching_sha2_password'

    首先从本地登录mysql数据库,进入mysql控制台,输入如下命令: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_passwo ...

  8. Ubuntu下使用mysqli-connect连接mysql时报错:ERROR 1698 (28000): Access denied for user 'root'@'localhost'

    LNMP安装好后,写了个index.php文件,里面的内容很简单,就是想测试php与mysql的通信是否正常,代码如下: <?php $host = 'localhost'; $user = ' ...

  9. jdbc连接oracle时报错 Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableC

    错误: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; ...

随机推荐

  1. OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系

    OpenGL ES 是负责 GPU 工作的,目的是通过 GPU 计算,得到一张图片,这张图片在内存中其实就是一块 buffer,存储有每个点的颜色信息等.而这张图片最终是要显示到屏幕上,所以还需要具体 ...

  2. 使用oid2name列出数据库和对应的oid

    [postgres@postgre base]$ ll total 172 drwx------ 2 postgres postgres 12288 Dec 6 09:21 1 drwx------ ...

  3. Linux交换空间(swap space)的那些优缺点

    下面的所有例子都在ubuntu-server-x86_64 16.04下执行通过 什么是swap? swap space是磁盘上的一块区域,可以是一个分区,也可以是一个文件,或者是他们的组合.简单点说 ...

  4. QML使用C++对象

    一.定义QObject子类 Myudp.h #ifndef MYUDP_H #define MYUDP_H #include <QObject> #include <QUdpSock ...

  5. 【407】C函数中的指针

    注意:如果对于函数中指针参数的对应值进行修改,当调用该函数后,实参会被修改,所以如果不想要实参被修改,需要为函数的形参定义一个 str_copy 的量,通过 strcpy() 进行将字符串复制给 st ...

  6. SpringCloud学习成长之路三 服务消费者(Feign)

    一.Feign简介 Feign是一个声明式的伪Http客户端,它使得写Http客户端变得更简单.使用Feign,只需要创建一个接口并注解. 它具有可插拔的注解特性,可使用Feign 注解和JAX-RS ...

  7. HTML、CSS之查遗补漏

    inline-block3个额外像素宽度问题 先看下例子: Title .sp{ /*border: 1px solid lightcoral;*/ display: inline-block; he ...

  8. Apache2.4的三种模式

    prefork 多进程模式 一个主进程,负责生成多个子进程,也称工作进程,进程之间独立,每个进程之间只能有一个线程,优点是稳定,缺点是内存占用大,每个进程响应一个用户请求. worker 多线程模式 ...

  9. Struts 2 --ONGL介绍

    先了解一下OGNL的概念 OGNL的全名称Object Graph Navigation Language.全称为对象图导航语言,是一种表达式语言.使用这种表达式语言,你可以通过某种表达式语法,存取J ...

  10. 【c# 学习笔记】封装

    封装 指的是把类内部的数据隐藏起来,不让对象实例直接对其操作.c#中提供了属性机制来对类内部的状态进行操作. 在c#中,封装可以通过Public.Private.Protected和Internal等 ...