连接数据库:ERROR: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 prop
本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-connector-java了,找到一个网站https://mvnrepository.com/,里面可以索引maven中心仓库,搜索mysql-connector-java
我选择了6.0.6进行配置
这下就出问题了,运行了一个jdbc程序,就出现标题所提到的问题了,是因为数据库驱动版本太高了,数据库和系统时区的差异所造成的,解决办法有两个:
一、换成低版本的驱动,比如5.1.43版本的
二、在mysql中执行命令
set global time_zone='+8:00'
或者在数据库驱动的url后加上serverTimezone=UTC参数(时区参数)
如果serverTimezone是第一个参数(?后面就是),则
jdbc:mysql://localhost/tradeonline?serverTimezone=GMT
如果serverTimezone不是第一个参数,则
jdbc:mysql://localhost/tradeonline?characterEncoding&serverTimezone=GMT
但是这样写会报错的The reference to entity “serverTimezone” must end with the ‘;’ delimiter. (对"serverTimezone"的引用必须以';'分隔符结尾)的错误提示,将代码改为:
jdbc:mysql://localhost/tradeonline?characterEncoding&serverTimezone=GMT
因为在XML配置时,要用&代替。另外,如果需要使用gmt+8时区,需要写成GMT%2B8,否则会被解析为空。(PS:数据库驱动JDBC新版本的名字改成了com.mysql.cj.jdbc.Driver)
连接数据库:ERROR: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 prop的更多相关文章
- mysql java.sql.SQLException: 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 zo ...
- 关于MySql升级JDBC架包导致时区问题报错(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. ...
- 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
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more tha ...
- 报错:Cannot create PoolableConnectionFactory (The server time zone value 'CST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverT
报错:Cannot create PoolableConnectionFactory (The server time zone value 'CST' is unrecognized or repr ...
- 【转载】在使用JDBC连接MySql时报错: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
在使用JDBC连接MySql时报错:You must configure either the server or JDBC driver (via the serverTimezone config ...
- You must configure either the server or JDBC driver (via the serverTimezone configuration property
使用JDBC连接MySql时出现:The server time zone value '�й���ʱ��' is unrecognized or represents more than one ...
- 三、SpringBoot启动时JDBC报错:You must configure either the server or JDBC driver (via the serverTimezone configuration property)
错误提示: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connectio ...
- 使用JDBC连接MySql时出现: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
在连接字符串后面加上?serverTimezone=UTC 其中UTC是统一标准世界时间. 完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTime ...
- The server time zone value 'EDT' is unrecognized or represents more than one time zone
解决: (1)使用 server mysql start命令启动mysql (2)在mysql中执行show variables like '%time_zone%'; (3)输入select now ...
随机推荐
- 浅谈Android发展趋势分析
去年11月16.17日,我有幸参加了北京2017安卓技术大会,做了关于车载Android系统的演讲,并主持了诸多大咖参与的圆桌讨论,对Android未来几年的发展趋势进行了一番讨论.来自小米.百度.高 ...
- 【ZJOI2005】沼泽鳄鱼 题解报告
题目描述 潘塔纳尔沼泽地号称世界上最大的一块湿地,它地位于巴西中部马托格罗索州的南部地区.每当雨季来临,这里碧波荡漾.生机盎然,引来不少游客. 为了让游玩更有情趣,人们在池塘的中央建设了几座石墩和石桥 ...
- HDU.1166 敌兵布阵 (线段树 单点更新 区间查询)
HDU.1166 敌兵布阵 (线段树 单点更新 区间查询) 题意分析 加深理解,重写一遍 代码总览 #include <bits/stdc++.h> #define nmax 100000 ...
- 使用Hystrix进行微服务降级管理
前言:目前我们的项目是微服务架构,基于dubbo框架,服务之间的调用是通过rpc调用的.刚开始没有任何问题,项目运行健康.良好.可是过了一段时间,线上总有人反应查询订单失败,等过了一段时间才能查到.这 ...
- 虚拟机安装ubuntu14.04.5系统
参考教程 在vitualbox安装 ubuntu14.04.2 LTS教程 http://jingyan.baidu.com/article/46650658228345f549e5f8cc.html ...
- shell 脚本判断linux 的发行版本
原文vi ./Get_Dist_Name.sh #!/bin/bash Get_Dist_Name() { if grep -Eqii "CentOS" /etc/issue || ...
- linux shell学习二
参考:http://www.cnblogs.com/waitig/p/5531463.html Shell注释 Shell中的注释以“#”号开头,所有以“#”号开头的代码都会被解释器所忽略. 比如下面 ...
- Eclipse 反编译插件
很多时候在项目开发中,没有源码是挺痛苦的一件事情,我们要知其然,更要知其所以然,但是有些公司就是不提供源码,怎么办? 不怕,下面教大家在Eclipse下安装反编译插件,方便好用. 好了,点 点 点 都 ...
- Google Map API 应用实例说明
目录 Google Map API 1基础知识 1.1 Google 地图 API 概念 1.2 Google 地图的"Hello, World" 1.2.1 加载 Google ...
- HDU 3507 单调队列 斜率优化
斜率优化的模板题 给出n个数以及M,你可以将这些数划分成几个区间,每个区间的值是里面数的和的平方+M,问所有区间值总和最小是多少. 如果不考虑平方,那么我们显然可以使用队列维护单调性,优化DP的线性方 ...