JDBC报错:The server time zone value is unrecognized or represents more than one time zone 已解决
一、详细报错信息
Caused by: 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.at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)at java.sql.DriverManager.getConnection(DriverManager.java:664)at java.sql.DriverManager.getConnection(DriverManager.java:247)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.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2120)at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2143)at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)... 17 more
二、报错原因
mysql 8.x 的 jdbc,增加了时区(serverTimezone)属性,并且不允许为空。
三、解决
- 这种方法会存在一个问题,在向数据库插入时间字段时,时间会比当前时间早8小时,即当前系统时间减8小时。
jdbc.url=jdbc:mysql://localhost:3306/mydata?
serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
- 这种设置成东八区,可以同步数据插入时间与当前系统时间
jdbc.url=jdbc:mysql://localhost:3306/mydata?
serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
- 在1884年的国际本初子午线大会上格林尼治的子午线被正式定为经度的起点。东经180°即西经180°,约等同于国际换日线,国际换日线的两边,日期相差一日。
格林威治标准时间(GMT)
地区:英国 皇家格林尼治天文台
时区:UTC/GMT 0 (零时区)
北京时差:现在格林威治时间比北京时间晚8小时
格林威治位于泰晤士河南岸,与北岸城镇通隧道和公路。1423年格洛斯特公爵亨天雷围建了格林尼治公园,在河畔山丘建了镃望塔,后又建造了格林威治皇家天文台。
协调世界时(UTC)
UTC协调世界时即格林威治平太阳时间,是指格林威治所在地的标准时间,也是表示地球自转速率的一种形式,UTC基于国际原子时间。
JDBC报错:The server time zone value is unrecognized or represents more than one time zone 已解决相关推荐
- 解决Hibernate报错The server time zone value is unrecognized or represents more than one time zone
解决Hibernate报错The server time zone value is unrecognized or represents more than one time zone 笔者在使 ...
- 【杂文】spring-boot报错 ~ zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than on time zone.
spring-boot报错 zone value 'Öйú±ê׼ʱ¼ä' is unrecognized 修改MySQL的配置文件(failed) 更改MySQL中的系统时间(failed) 修 ...
- 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 ...
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
Spring Cloud启动jdbc报错 1.Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The s ...
- 解决The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than one time zone问题
问题描述 数据库配置如下 spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://192.168. ...
- The server time zone value is unrecognized or represents more than one time zone. 这个问题的解决方法
我在用spring boot开发jpa的时候,发现了这个问题: The server time zone value '???ú±ê×??±??' is unrecognized or represe ...
- The server time zone value ‘‘ is unrecognized or represents more than one time zone.
The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You ...
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone问题解决
今天在使用JDBC连接数据库时出了一点问题: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver cla ...
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
场景 运行Mybatis的generator自动生成代码时提示: caused by :The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognize ...
最新文章
- 2字节取值范围_第二篇——整数和浮点数在计算机中的表示(2)
- 各色“独特的”数据中心安置法,藏太深了!
- IBase component cannot be created and deleted in the same second
- 浮点数计算机的表示案例,计算机中的数据及其应用案例.docx
- RUNOOB python练习题 32 列表的中括号符号小tips
- monkey测试===通过monkey测试检查app内存泄漏和cpu占用
- php课程---JavaScript与Jquery的区别(转)
- el表达式 多条件判断
- 计算机专业论文选题网站方面,5大网站汇总,搞定新颖的计算机专业毕业设计网站汇总...
- 计算机鼠标样式,告诉你电脑如何更改鼠标的指针样式?
- Android Studio模拟器磁盘空间不足(Not enough disk space to run AVD)
- 如何弥补mac系统存在的局限性
- PRML第三章之回归的线性模型
- 数据结构面试题以及答案整理
- 疫情让鲸类暂时远离了人工噪声,但在这之前,它们已被打扰了一百多年
- okr与项目管理区别?
- matlab 四面体,《有限元基础教程》【MATLAB算例】481基于4节点四面体单元的空间块体分析(Tetrahedron3D4Node)...
- 双赞的一体机主板能应用到哪些行业?
- 微信小程序幻灯片效果实现
- lua web快速开发指南(7) - 高效的接口调用 - httpc库
热门文章
- vue-父子组件传参以及无限级评论
- Just For Fun(乐者为王)——Linux创始人
- c语言实验作业在dev蜗居的思路,C语言程序设计实验(共5篇)
- 进制详解:二进制、八进制和十六进制
- 吊打 CLIP 平均10个点,Meta 多模态通用模型 FLAVA真香啊
- linux开源社区贡献代码,4岁小萝莉向Linux内核贡献代码修复「漏洞」而且代码已经合并到内核...
- [渝粤教育] 信阳师范学院 视听语言 参考 资料
- 【运维实战家】无线三建七优之频信优传-锐捷无线
- 淘宝开放平台签名验证失败
- 玩转黑群晖(持续更新)