JDBC/Mybatis连接数据库报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
造成这个的原因是maven导入MyBatis的时候会自动导入最新版本的8.0.11,然后8.0.11采用了新驱动,之前版本会报错。
当我们使用高版本的MySQL驱动时可以在获取数据库的连接getConnection()的url后面加上serverTimezone=GMT。
修改数据库连接url:jdbc:mysql://test?&serverTimezone=GMT。但是没有解决我的问题!
我解决的办法是:修改数据库的默认时区:
1、登录mysql数据库
2、执行如下sql,没有设置之前value的值是system,因为我已经修改了,所以显示的是+08:00
show variables like '%time_zone%';

3、使用如下sql修改默认时区:
set global time_zone = '+8:00';
4、退出重新登录,查看当前时间,和当前时间做比较,发现修改成功
select now();
问题得到解决!
还有一种解决办法是:使用低版本的MySQL jdbc驱动5.1.28,低版本的不会存在时区的问题。但是使用低版本的驱动的话会有如下异常:
java.sql.SQLException: Unknown system variable 'query_cache_size'
这个异常是因为:query cache在MySQL5.7.20就已经过时了,而在MySQL8.0之后就已经被移除了。
所以这种解决办法还是行不通!
JDBC/Mybatis连接数据库报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.的更多相关文章
- JDBC连接数据库报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ......
问题:Java程序使用JDBC连接MySQL数据库时,控制台报错如下: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' ...
- mysql报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
mybatis链接mysql,启动服务报错: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecogni ...
- SpringBoot报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
解决方法: 在数据库连接url配置后边加&serverTimezone=GMT%2B8 例: jdbc:mysql://127.0.0.1:3306/test改为jdbc:mysql://12 ...
- 连接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 ...
- 【JDBC】java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
在使用阿里的druid 时,报了一个异常java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized ...
- 异常: 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 configurat
异常: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ...
- JDBC告警系列(一)The server time zone value 'ÖÐ' is unrecognized or represents more than one time zone.
一.现象 java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents ...
- 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 server
错误信息 java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents ...
- spring boot启动异常: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
项目启动时提示:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represen ...
随机推荐
- C# ProgressBar的简单使用
ProgressBar控件(进度条)用于在win窗体中显示进度,由于它的值会不断更新,为了不让界面假死,一般都是采用多线程的方式对进度条进行管理.有关ProgressBar的理论基础跟详细知识我在这里 ...
- TP5实现多文件上传及展示
view层上传: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- think php 删除
表单页面 <a href="/examtest/test/edit/id/{$v['id']}">修改</a> <a href="/exam ...
- Java学习笔记:02面向对象-重写_this_super_抽象类
02面向对象-重写/this/super/抽象类 ****1.this和super 作用: this: 区分本类的成员变量和局部变量同名情况 super:区分父类的成员变量和局部变量同名情况 用法: ...
- OCCT基础
基础 构成总览 Root类 基本类型,如布尔,字符,整数或实数 安全处理动态创建的对象,确保自动删除未引用的对象 可配置的内存管理器,提高了应用程序的性能 包含运行时类型信息机制,有助于创建复杂应用 ...
- angularJs 指令的用法
<!DOCTYPE html><html ng-app='app'><!--A attribute属性:当做属性来使用<div xingoo></div ...
- 配置jenkins+git+python实现接口自动化持续集成
1.安装jenkins服务(傻瓜式安装,这里不做描述) 2.windows上访问jenkins地址(http://ip:端口号/),用户名密码登录 3.进入后新建一个job 4.Source Code ...
- sem信号量与死锁的边缘
1. 演示一个例子,出现死锁,用strace debug得到 #include<stdio.h> #include<pthread.h> #include<stdlib. ...
- ArrayList如何实现插入的数据按自定义的方式有序存放?
编程思路是:实现一个类对ArrayList进行包装,当程序试图向ArrayList中放入数据时,程序将先检查该元素与ArrayList集合中其他元素的大小,然后将该元素插入到指定位置. class M ...
- 为什么redis 需要把所有数据放到内存中?
答:Redis 为了达到最快的读写速度将数据都读到内存中,并通过异步的方式将数 据写入磁盘.所以 redis 具有快速和数据持久化的特征.如果不将数据放在内存中, 磁盘 I/O 速度为严重影响 red ...