连接数据库: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 ...
随机推荐
- javascript的解析顺序
一.javascript的解析顺序 我们大家所理解的代码的执行顺序都是从上到下的,但是实际上确不是这样的.我们看一下下面的代码. 1 alert(a);2 var a = 1;如果执行顺序是从上到下的 ...
- 【BZOJ3105】新Nim游戏(线性基)
[BZOJ3105]新Nim游戏(线性基) 题面 BZOJ Description 传统的Nim游戏是这样的:有一些火柴堆,每堆都有若干根火柴(不同堆的火柴数量可以不同).两个游戏者轮流操作,每次可以 ...
- 使用adb命令查看apk版本
adb devices (显示连接的设备) adb root (获取手机root权限) adb remount (重新挂载系统分区,使系统分区重新可写) adb shell (进入目标设备的L ...
- 2656: [Zjoi2012]数列(sequence)(递归+高精度)
好久没写题了T T NOIP 期中考双血崩 显然f(x)=f(x>>1)+f((x>>1)+1),考虑每次往x>>1递归,求出f(x),复杂度O(logN) 我们设 ...
- 【codechef】Children Trips
Portal -->CC_Children Trips Solution (英文题解看得真爽qwq不过写的好详细啊ovo) 首先这题有一个很重要的条件就是边权是\(1\)或者\(2\),所以虽然 ...
- 【DP】【P5007】 DDOSvoid 的疑惑
Description 给定一棵以 1 为根的有根树,定义树的一个毒瘤集为一个集合,并且集合中任意两个元素之间不存在祖先与后代关系. 定义一个毒瘤集的毒瘤指数为集合内所有元素的价值之和 要求给定树的所 ...
- Overlaying GPS Coordinates for Camera Crosshairs
Hey Guys! I am working on a project to allow us to implement GPS coordinates for the location of the ...
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) F dfs序+树状数组
Performance ReviewEmployee performance reviews are a necessary evil in any company. In a performance ...
- 【题解】彩色树 51nod 1868 虚树 树上dp
Prelude 题目在这里:ο(=•ω<=)ρ⌒☆ Solution 蒟蒻__stdcall的第一道虚树题qaq. 首先很容易发现,这个排列是假的. 我们只需要求出每对点之间的颜色数量,然后求个 ...
- 2017 国庆湖南 Day3
期望得分:100+30+60=190 实际得分:10+0+55=65 到了233 2是奇数位 或223 第2个2是偶数位就会223 .233 循环 #include<cstdio> #de ...