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 ...
随机推荐
- 修复因为存储空间问题引起的nexus 服务启动异常
故障描述 因为nexus所在服务器存储空间满了, 做了部分清理操作,结果nexus 启动异常,提示错误信息基本类似如下: build 285537d2767275f460df32c6a3be01b ...
- python selenium-webdriver 执行js (八)
使用python selenium 做自动化测试的时候其实我基本没有使用过执行js,只是在后来使用selenium来爬虫的时候使用到了,所以我在这里也就拿出来简单的介绍一下如何执行js. execut ...
- 优化IIS7.5支持10万个同时请求的配置方法
通过对IIS7的配置进行优化,调整IIS7应用池的队列长度,请求数限制,TCPIP连接数等方面,从而使WEB服务器的性能得以提升,保证WEB访问的访问流畅. IIS7.5是微软推出的最新平台IIS,性 ...
- 如何使用Visual Studio Code开发Django项目
如何获得 Visual Studio Code 访问 http://code.visualstudio.com 下载并安装. 前提条件 安装Python 2.7 及 Python 3.5,Window ...
- python列表的基础操作
Operation Result Trans x in s True if an item of s is equal to x, else False x值是否在s列表中 x not in s Fa ...
- iOS XML解析使用-韩国庆
欢迎-------(北京-iOS移动开发金牌教师QQ:2592675215)韩老师给你带来XML解析课程 今天给大家讲解下xml解析的第三方简单用法:首先我解释下,json和xml解析格式. JSON ...
- [STM32F103]RTC日历
使能PWR和BKP时钟: a) RCC_APB1PeriphClockCmd(); 使能后备寄存器访问: a) PWR_BackupAccessCmd(); 配置RTC时钟源,使能RTC时钟: a) ...
- Class.forName的作用?为什么要用?
答:按参数中指定的字符串形式的类名去搜索并加载相应的类,如果该类字节码已经被加载过,则返回代表该字节码的Class实例对象,否则,按类加载器的委托机制去搜索和加载该类,如果所有的类加载器都无法加载到该 ...
- java异常处理——finally相关
示例程序1 public class EmbededFinally { public static void main(String args[]) { int result; try { Syste ...
- Docker镜像仓库Harbor搭建及配置
一.harbor简介 Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全.标识和管理等,扩展了开源Docker Distribut ...