本打算在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的更多相关文章

  1. 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 ...

  2. 关于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. ...

  3. 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 ...

  4. 报错: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 ...

  5. 【转载】在使用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 ...

  6. 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 ...

  7. 三、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 ...

  8. 使用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 ...

  9. 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 ...

随机推荐

  1. BZOJ1176:[Balkan2007]Mokia——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=1176 Description(题面本人自行修改了一下) 维护一个W*W的矩阵,初始值均为0.每次操作 ...

  2. [HEOI2016/TJOI2016]求和——第二类斯特林数

    给你斯特林数就换成通项公式,给你k次方就换成斯特林数 考虑换成通项公式之后,组合数没有什么好的处理方法 直接拆开,消一消阶乘 然后就发现了(j-k)和k! 往NTT方向靠拢 然后大功告成 其实只要想到 ...

  3. C++中Vector求最大值最小值

    vector<int> v: 最大值: int max = *max_element(v.begin(),v.end()); 最小值: int min = *min_element(v.b ...

  4. MakeDown的使用

    Makedown的使用 之前有用博客园来写博客,但是因为它的界面不好看,所以中途就放弃了.后来也使用过"有道云笔记",发现其写的笔记的界面很简洁工整.有道云笔记的书写原理和Make ...

  5. bzoj 2502 清理雪道 (有源汇上下界最小流)

    2502: 清理雪道 Time Limit: 10 Sec  Memory Limit: 128 MB Description        滑雪场坐落在FJ省西北部的若干座山上. 从空中鸟瞰,滑雪场 ...

  6. DevExpress 常用命令包括导出-打印-打印预览等

    3.表格打印也是最常见的,打印代码如下: PrintingSystem ps = null; DevExpress.XtraPrinting.PrintableComponentLink link = ...

  7. 【CodeForces】889 C. Maximum Element 排列组合+动态规划

    [题目]C. Maximum Element [题意]给定n和k,定义一个排列是好的当且仅当存在一个位置i,满足对于所有的j=[1,i-1]&&[i+1,i+k]有a[i]>a[ ...

  8. spring-boot支持websocket

    spring-boot本身对websocket提供了很好的支持,可以直接原生支持sockjs和stomp协议.百度搜了一些中文文档,虽然也能实现websocket,但是并没有直接使用spring-bo ...

  9. input只读属性readonly和disabled的区别

    主要区别: 参考: http://bbs.html5cn.org/forum.php?mod=viewthread&tid=84113&highlight=input http://b ...

  10. 无key值的json数组解析

    [    [        {            "cartId": 9223,            "factoryId": 143,          ...