今天在用junit测试mybits程序是遇到一个问题,报错为:

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: 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 a more specifc time zone value if you want to utilize time zone support.
### The error may exist in com/po/User.xml
### The error may involve first.searchUserById
### The error occurred while executing a query
### Cause: java.sql.SQLException: 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 a more specifc time zone value if you want to utilize time zone support.
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
    at com.test.TestUser.testSearchUserById(TestUser.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4...

的时区(地理中的时区),是需要自己设置的,一般的UTC为世间标准时间,不属于任何时区,

UTC时区默认比北京时间晚8个小时,中国时区为CST。关于其它有关服务器时区与数据库的知识点,大家可以自己搜索了解,这里给大家推荐一篇文章

https://blog.csdn.net/vae1314chuanchen/article/details/81838476

那么怎么处理呢,在全局配置文件中找到:

 

<property name="url" value="jdbc:mysql://服务器地址:端口号/数据库名 />

在数据库名称后面加入:serverTimezone=UTC&amp;useSSL=false  ,如果,你的url后面还有其它参数则应该加入:serverTimezone=UTC&amp;useSSL=false&amp;

添加后为:

 <property name="url" value="jdbc:mysql://服务器地址:端口号/数据库名?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true"/>

如果后面还有参数(如设置编码)则为:

 <property name="url" value="jdbc:mysql://服务器地址:端口号/数据库名?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf-8" />

问题得到解决。

在下也是菜鸟一名,在这里是将学习过程中发现的问题,解决问题的方法分享出来,可能有不足之处请路过的大佬不吝赐教,小的将不胜感激。

org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents mor的更多相关文章

  1. org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NumberFormatException: For input string: "W%" ### Cause: java.lang.NumberFormatException: For input s

    一个常见的myBatis xml文件中的引号错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...

  2. org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manu

    这个是sql 语句 错误     仔细检查 SQL语句是否写错了 org.apache.ibatis.exceptions.PersistenceException: ### Error queryi ...

  3. org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent succ

    数据库 没有开启  连接失败 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause ...

  4. mybatis <fireach> 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause:

    <select id="getUserIn" parameterType="QueryVo" resultMap="userMap"& ...

  5. mybatis 执行查询时报错 【Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: 】

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLE ...

  6. 初学MyBatis(踩坑)Error querying database. Cause: java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long

    最近在学习Mybatis,代码全部根据教程写好了,一运行结果报了一个错误,主要错误内容: Caused by: org.apache.ibatis.exceptions.PersistenceExce ...

  7. Error querying database. Cause: java.sql.SQLException: ORA-01745: 无效的主机/绑定变量名

    今天调试程序是遇到了,下面的一个问题.我将对应的SQL语句拿到Toad下也能正常的执行,感觉有点莫名其妙,根据异常信息的提示查看对应的映射结果集也没发现错误,然后百度了一下,也有许多朋友也遇到过这样的 ...

  8. 使用Mybatis连接数据库时报错:org.apache.ibatis.exceptions.PersistenceException: ### Error updating database.

    我的原因是字段名写错了,去数据库中复制字段名再运行就成功了.

  9. Error updating database. Cause: java.sql.SQLException: Access denied for user '${username}'@'localhost' (using password: YES)

    导入别人的项目,出现一个错误,经过排查,是db.properties配置文件中的用户名与Mybatis-conf.xml配置文件中调用的用户名不一致所导致的 (db.properties中用的是nam ...

随机推荐

  1. 微信小程序-饮食日志_开发记录02

    此段时间主要写功能的实现. 内部的增删改查等内容. 主要有食物查找.运动选择.身高体重比例计算等.

  2. SpringBoot框架(6)--事件监听

    一.场景:类与类之间的消息通信,例如创建一个对象前后做拦截,日志等等相应的事件处理. 二.事件监听步骤 (1)自定义事件继承ApplicationEvent抽象类 (2)自定义事件监听器,一般实现Ap ...

  3. java 流操作对文件的分割和合并的实例详解_java - JAVA

    文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 java 流操作对文件的分割和合并的实例详解 学习文件的输入输出流,自己做一个小的示例,对文件进行分割和合并. 下面是代 ...

  4. .net2.0 Thread 多线程

    序言 第1章  线程基础 System.Threading Join C#中的Thread中的ApartmentState几种状态(STA,MTA,Unknown)详解 System.Threadin ...

  5. HDU 6651 Final Exam

    hdu题面 Time limit 2000 ms Memory limit 524288 kB OS Windows 吐槽 比赛时候晕死了-- 解题思路 先留坑 公式法 https://blog.cs ...

  6. CCA(典型相关分析)

    https://www.cnblogs.com/pinard/p/6288716.html

  7. 01-scrapy框架

    1.Scrapy图例: Scrapy Engine(引擎): 负责Spider.ItemPipeline.Downloader.Scheduler中间的通讯,信号.数据传递等. Scheduler(调 ...

  8. jenkins 管理员密码重置

    jenkins管理员 admin的密码忘记怎么重置呢? 修改admin的加密密码为123456的加密密码 #jbcrypt:$2a$10$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNp ...

  9. BZOJ 2281 Luogu P2490 [SDOI2011]黑白棋 (博弈论、DP计数)

    怎么SDOI2011和SDOI2019的两道题这么像啊..(虽然并不完全一样) 题目链接: (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?i ...

  10. BZOJ 3143 Luogu P3232 [HNOI2013]游走 (DP、高斯消元)

    题目链接: (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=3143 (luogu) https://www.luogu.org/pro ...