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 ...
随机推荐
- vue--按需加载的3种方式(解决网页首次加载速度慢的问题)
一.vue的异步组件加载 使用异步组件加载,打包的时候会将每个组件分开打包到不同的js文件中: {path: '/index', name: 'index', meta:{ title:'首页', r ...
- 『现学现忘』Docker基础 — 14、Docker的卸载
目录 1.查询Docker安装过的包 2.卸载Docker软件包 3.删除残留目录 4.验证是否卸载 5.20版本Docker卸载(官方文档) 1.查询Docker安装过的包 执行yum list i ...
- mysql sql_mode=only_full_group_by问题临时解决
执行代码 set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZER ...
- 打靶笔记-03-vulhub-Moriarty Corp
打靶笔记-03-vulhub-BoredHackerBlog 一.靶机信息 Name: BoredHackerBlog: Moriarty Corp(中-高级难度) Date release: 29 ...
- 关于 jmeter变量是否在引用时候需要加上引号的坑
今天在玩jmeter的时候,发现一个问题:一个关于 jmeter变量是否在引用时候需要加上引号的坑: 众所周知:jmeter引用变量的时候 需要使用${变量名} 但是:大家是否遇到过有时候变量名外需要 ...
- 除非Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站。
解决办法: 打开WINDOWS服务管理方法: 进入服务有二种方法: 1.开始-控制面板-管理工具单击,找到"服务"双击打开 在WINDOWS服务管理里 启动 World Wide ...
- redis哨兵功能
redis哨兵功能 redis-Sentinel(哨兵) 前言 当用redis作master-slave的高可用时,如果master本身宕机,redis本身或者客户都没有实现主从切换的功能 redis ...
- python练习册 每天一个小程序 第0002题
1 #-*-coding:utf-8-*- 2 __author__ = 'Deen' 3 ''' 4 题目描述: 5 将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型 ...
- markdown类型文件编辑大全
正文: 1.标题的几种写法: 第一种: 前面带#号,后面带文字,分别表示h1-h6,上图可以看出,只到h6,而且h1下面会有一条横线,注意,#号后面有空格 第二种: 这种方式好像只能 ...
- linux的文件与目录的权限设置
@font-face { font-family: 宋体 } @font-face { font-family: "Cambria Math" } @font-face { fon ...