本打算在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. Ckeditor与Ckfinder(java)整合实现富媒体内容编辑(支持文件上传)

    先来看一下最终的效果图 一.编辑器界面 二.上传图片界面 <!-------------------------------------------------------> 一.安装包下 ...

  2. 【BZOJ4889】不勤劳的图书管理员(树套树)

    [BZOJ4889]不勤劳的图书管理员(树套树) 题面 又是权限题,烦死了 洛谷真好 题解 分开考虑每一次交换产生的贡献. 假设交换\((x,y)\) 检查\(x\)与\(y\)对于区间\([x+1, ...

  3. 【BZOJ2437】【NOI2011】兔兔与蛋蛋(博弈论,二分图匹配)

    [BZOJ2437][NOI2011]兔兔与蛋蛋(博弈论,二分图匹配) 题面 BZOJ 题解 考虑一下暴力吧. 对于每个状态,无非就是要考虑它是否是必胜状态 这个直接用\(dfs\)爆搜即可. 这样子 ...

  4. 强大工具psexec工具用法简介

    原文链接地址:https://www.cnblogs.com/boltkiller/articles/4791307.html psexec是sysinternals的一款强大的软件,通过他可以提权和 ...

  5. C++——内存对象 禁止产生堆对象 禁止产生栈对象

    用C或C++写程序,需要更多地关注内存,这不仅仅是因为内存的分配是否合理直接影响着程序的效率和性能,更为主要的是,当我们操作内存的时候一不小心就会出现问题,而且很多时候,这些问题都是不易发觉的,比如内 ...

  6. 《JavaScript高级程序设计(第三版)》-3

    相等操作符 相等和不相等 在转换不同的数据类型时,相等和不想等操作符遵循下面基本规则: 如果有一个操作符数是布尔值,则在比较相等性之前先将其转换为数值——false转换为0,而true转换为1: 如果 ...

  7. HDU 4638 莫队算法

    Group Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  8. c#代码访问https服务器以及https的webservice

    代码访问https类似浏览器操作 1.验证证书 2.如果要求客户端证书,提供客户端证书 具体代码如下: 访问https的web public static void ProcessRequest() ...

  9. sqlserver 2008连接

    初次安装使用SQL server 2008时,可能会遇到无法连接到(local)的情况.那么,如何解决此问题?   工具/原料   SQL server 2008 方法/步骤   1 打开SQL se ...

  10. poi复杂excel的实现

    一:前言 最近帮一个朋友做excel的导出功能,对于我来说还是挺头疼,我看了下表格样式,对于我来说还是挺头疼的,想当年耗子刚刚出社会的时候做的第一份工作,第一份任务就是把把word转换为html,在这 ...