今天在用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. 通过继承Thread类实现多线程

    (1)继承Thread类(2)重写run(方法(3)通过start0方法启动线程 一定的缺点: Java中的类是单继承的,一旦继承了Thread类,就不允许再去继承其它的类 线程和主方法之间的执行顺序 ...

  2. thinkphp类型转换

    类型转换 说白了就是在model类中声明的字段输出类型:其语法如下: 注意strtotime()函数可以将诸如‘2018-12-21’这样的日期字符串转为整数存入数据库 自动完成---等于提前对某一表 ...

  3. linux的字符集转换

    命令查看编码类型 查看命令参数 查看支持的字符集 将文件转换成utf-8 的文件(经测试比较鸡肋,不好用) [root@ag-1 hh]# iconv oldboy -f us-ascii -t ut ...

  4. 微信长按识别二维码,在 vue 项目中的实现

    微信长按识别二维码是 QQ 浏览器的内置功能,该功能的基础一定要使用 img 标签引入图片,其他方式的二维码无法识别. 在 vue 中使用 QrcodeVue 插件 demo1 在 template ...

  5. springboot集成fastjson

    @Configuration @EnableWebMvc public class WebMvcConfigurer extends WebMvcConfigurerAdapter { /** * f ...

  6. java开发需掌握技能1

    1.熟练掌握Java基础.语法规范.集合框架等,基础语法.Java关键字.内部类.泛型.集合类使用场景2.Java io/nio框架体系.文本文件.二进制文件读写.nio.buffer机制3.Jsp. ...

  7. jconsole性能监控

    1.进入tomcat bin目录 vim catalina.sh #!/bin/sh下面加入: #!/bin/shJAVA_OPTS="-Dcom.sun.management.jmxrem ...

  8. mssql的sql注入拿后台

    0x01判断数据 ①判断数据库类型 and exists (select * from sysobjects)--返回正常为mssql(也名sql server) and exists (select ...

  9. instanceOf与isInstance()方法之间的区别

    instanceof运算符 只被用于对象引用变量,检查左边的被测试对象 是不是 右边类或接口的 实例化.如果被测对象是null值,则测试结果总是false.Class类的isInstance(Obje ...

  10. 20175308 实验三《敏捷开发与XP实践》

    20175308 实验三<敏捷开发与XP实践> 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程 完成实验.撰写实验 ...