本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-connector-java了,找到一个网站https://mvnrepository.com/,里面可以索引maven中心仓库,搜索mysql-connector-java

我选择了6.0.6进行配置

这下就出问题了,运行了一个jdbc程序,就出现标题所提到的问题了,是因为数据库驱动版本太高了,数据库和系统时区的差异所造成的,解决办法有两个:

一、换成低版本的驱动,比如5.1.43版本的

二、在mysql中执行命令

  1. set global time_zone='+8:00'

或者在数据库驱动的url后加上serverTimezone=UTC参数(时区参数)

如果serverTimezone是第一个参数(?后面就是),则

  1. jdbc:mysql://localhost/tradeonline?serverTimezone=GMT

如果serverTimezone不是第一个参数,则

  1. jdbc:mysql://localhost/tradeonline?characterEncoding&serverTimezone=GMT

但是这样写会报错的The reference to entity “serverTimezone” must end with the ‘;’ delimiter. (对"serverTimezone"的引用必须以';'分隔符结尾)的错误提示,将代码改为:

  1. 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. Thuwc2018 游记

    上一次没有滚粗的比赛已经是9个月前了QAQ.但我现在回过头去看那篇“zjoi游记”,却发现自己并不能从中得到收获.希望这次写下的东西,可以帮助我更好地准备即将到来的省选(雾) day 0 火车上浪10 ...

  2. CODECHEF Chef and Churus 解题报告

    [CODECHEF]Chef and Churus Description 有一个长度为\(n\)的数组\(A\),有\(n\)个函数,第\(i\)个函数的值为\(\sum_{j=l_i}^{r_i} ...

  3. RDD 算子补充

    一.RDD算子补充 1.mapPartitions         mapPartitions的输入函数作用于每个分区, 也就是把每个分区中的内容作为整体来处理.   (map是把每一行) mapPa ...

  4. 服务器上的 Git - 生成 SSH 公钥

    http://git-scm.com/book/zh/ch4-3.html 生成 SSH 公钥 如前所述,许多 Git 服务器都使用 SSH 公钥进行认证. 为了向 Git 服务器提供 SSH 公钥, ...

  5. Codeforce 633.C Spy Syndrome 2

    C. Spy Syndrome 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. Python2和Python3共存安装

    记录下: 先下载Python2.7.6,安装完成,不要添加到path中: 再下载Python3.4.3,安装,不要添加到path中. 进入 Python2: py -2 进入Python3: py - ...

  7. python 删除文件/夹

    原文 : http://www.cnblogs.com/SophiaTang/archive/2012/01/16/2323467.html import os 删除文件: os.remove() 删 ...

  8. 分布式监控系统开发【day37】:监控数据如何存储(七)

    一.如何存储 二.目录结构 三.代码调用逻辑关系 四.实现代码 1.data_optimization 1.存筛选出来符合条件的数据 def get_data_slice(self,lastest_d ...

  9. 深入探索C++对象模型(七)

    站在对象模型的尖端(On the Cusp of the Object Model) Template 下面是有关template的三个主要讨论方向: template的声明,基本上来说就是当你声明一 ...

  10. 洛谷 2186 小Z的栈函数

    https://www.luogu.org/problem/show?pid=2186 题目描述 小Z最近发现了一个神奇的机器,这个机器的所有操作都是通过维护一个栈来完成的,它支持如下11个操作: N ...