MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???׼ʱ?' is unrecognized or represents more than one time zone.
JDBC访问MySql异常
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: 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.
原因分析:
数据库安装时默认为英语,0:00时区
Windows系统中,XP的时区是GMT,而Win7的时区是UTC。
mysql返回的时间会比实际时间要早8小时。
解决方案,以下任选一种即可解决问题:
1、配置JDBC连接参数
在url连接字符串后面加上?serverTimezone=UTC
例如:
jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF8&serverTimezone=UTC
学点新知识:
UTC,世界均衡时间
GMT,格林尼治时间
北京时间(东八区),GMT+8,url中表示为:&serverTimezone=GMT%2B8
jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=GMT%2B8
我们一般认为GMT和UTC是一样的,都与英国伦敦的本地时相同。
2、修改MySQL数据库配置,需要DBA的root权限
使用root用户登录mysql
--查看时区值
show variables like '%time_zone%';
--设置为东八区(北京时间)
set global time_zone='+8:00';
3、有人说,使用低版本的MySQL jdbc驱动,5.1.47不会存在时区的问题,的确如此。
MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???׼ʱ?' is unrecognized or represents more than one time zone.的更多相关文章
- 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized...解决方法
今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or r ...
- 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 ...
- Eclipse使用jdbc连接MySql数据库报:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
在使用eclipse连接mysql数据库时报异常: java.sql.SQLException: Access denied for user 'root'@'localhost' (using pa ...
- ssm框架下 数据库连接异常 java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more
1.错误截图 2.修改操作 我是在框架的中连接的数据库,如果在类中把 &换成& 修改前代码 <property value="com.mysql.jdbc.Dri ...
- java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ 解决方案
//第一个异常 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysq ...
- 【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 ...
- 解决java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
使用spring boot整合MySQL时一直报 java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecog ...
- MySQL连接数据库报时区错误:java.sql.SQLException: The server time zone value
连接MySQL数据库时报以下时区错误信息: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized ...
- 【MySQL】java.sql.SQLException: The server time zone value
错误:Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: The se ...
随机推荐
- java的接口
接口(英文:Interface),在JAVA编程语言中是一个抽象类型,是抽象方法的集合,接口通常以interface来声明.一个类通过继承接口的方式,从而来继承接口的抽象方法. 接口并不是类,编写接口 ...
- JS实现购物商城商品放大
img属于行内元素 <img src=''>gq</img> 效果 当放大图片时候,文字位置发生改变 文字出现在图片下方,因为图片有一个隐形的g线,这条线的位置和以前上学时候, ...
- C语言题库----指针
1.如果f是一个函数,请说明 f() 和f的意思. f是函数的地址,f()是函数 2.怎样理解数组的下标运算? 先偏移,后取址. 3.int *p,*q; int a[]={10,20,30,40}; ...
- bootstrap简单使用实例
表格实例,包含bootstrap.css 和 2.1.1jquery <!DOCTYPE html> <html> <head> <meta charset= ...
- Scrapy 原理
Scrapy 原理 一.原理 scrapy 是一个为了爬取网站数据,提取结构性数据而编写的应用框架.可以应用在包括数据挖掘,信息处理或存储历史数据等一系列程序中. 二.工作流程 Scrapy Engi ...
- HBASE SHELL 命令使用
HBASE SHELL命令的使用 在hbase shell客户端有许多的操作命令,今天回顾并且总结一二,希望和广大读者共同进步,并且悉心聆听你们的意见.在此的hbase版本是:HBase 1.2.0- ...
- Java面向对象程序设计的六大基本原则
1.开闭原则(Open Close Principle) 定义:一个软件实体如类.模块和函数应该对扩展开放,对修改关闭. 开放-封闭原则的意思就是说,你设计的时候,时刻要考虑,尽量让这个类是足够好,写 ...
- WebService之客户端
创建项目 File→New→Other→Web Services→Web Service Client中输入从服务端得到的wsdl链接: http://localhost:8080/WS_WebSer ...
- 用openssl为WEB服务器生成证书(自签名CA证书,服务器证书)
用openssl为WEB服务器生成证书(自签名CA证书,服务器证书) 来源: https://www.cnblogs.com/osnosn/p/10608455.html 来自osnosn的博客 写于 ...
- 在 Linux 系统中读取 GBK 编码的文档
Linux 系统中,默认使用 UTF-8 编码.有时,我们下载的一些文件(比如 TXT 电子书,中文字幕等)使用了 GBK 编码,这样,当我们读取这些文件时,就会看到乱码.一般来说,有两种解决办法. ...