Exception in thread “main” 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.

解决方法

根据异常提示可知需要添加对应的时区,修改url即可

String url = String.format(“jdbc:mysql://%s:%d/%s?characterEncoding=%s&serverTimezone=UTC”, host, port, database, encoding);

在XML中

提示系统时区出现错误,可以在mysql中执行命令:

set global time_zone='+8:00' 
或者在数据库驱动的url后加上serverTimezone=UTC参数

写代码的时候要注意,如果该参数是‘?’后的第一个,即

<property name="jdbcUrl"> jdbc:mysql://localhost:3306/exam?serverTimezone=UTC </property>

是没有问题的,但如果不是第一个,即

<property name="jdbcUrl"> jdbc:mysql://localhost:3306/exam?characterEncoding=utf8&serverTimezone=UTC </property>

这种写法是会报错的,会提示The reference to entity “serverTimezone” must end with the ‘;’ delimiter. 
运行后控制台也会出现 
对实体 “serverTimezone” 的引用必须以 ‘;’ 分隔符结尾。 
的错误提示。 
将代码改为

<property name="jdbcUrl"> jdbc:mysql://localhost:3306/exam?characterEncoding=utf8&amp;serverTimezone=UTC </property>

即可。在xml的配置文件中 ;要用 &amp; 代替。

Exception in thread “main” java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone.的更多相关文章

  1. Exception in thread “main” java.sql.SQLException: No suitable driver

    问题背景:通过Spark SQL的jdbc去读取Oracle数据做测试,在本地的idea中没有报任务错误.但是打包到集群的时候报: Exception in thread “main” java.sq ...

  2. JDBC编程错误:Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)

    出现上面的错误是因为连接数据库的用户名不对或密码赋值不对,请对用户名和密码进行检查. 或者在程序中没有获取到正确的用户名或密码.看是否少写了用户名或密码.

  3. java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

    Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä ...

  4. Java 控制台执行带自定义包定义的类,出现“Exception in thread "main" java.lang.NoClassDefFoundError: ConnectSQLServer (wrong name: sine/ConnectSQLServer)”

    1.先说明一下代码实现:自定义package sine, 源代码保存路径为:E:\JSP\HibernateDemo\HibernateDemoProject\src\sine\ConnectSQLS ...

  5. Oozie时出现Exception in thread "main" java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor version 52.0?

    不多说,直接上干货! 问题详情 [hadoop@bigdatamaster oozie--cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -ru ...

  6. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/CanUnbuffer

    在执行spark on hive 的时候在  sql.show()处报错 : Exception in thread "main" java.lang.NoClassDefFoun ...

  7. Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, do

    继上一篇Hive: Exception in thread "main" java.lang.RuntimeException: Hive metastore database i ...

  8. Exception in thread "main" java.lang.NoClassDefFoundError: scala/Product$class

    在使用spark sql时一直运行报这个错误,最后仔细排查竟然是引入了两个scala library .去除其中一个scala的编译器即可 Exception in thread "main ...

  9. Exception in thread "main" java.lang.IllegalArgumentException: System memory 202768384 must be at least 4.718592E8. Please use a larger heap size.

    Spark-submit 提交任务时候报错 Exception in thread "main" java.lang.IllegalArgumentException: Syste ...

随机推荐

  1. Geometry Shader 【转】

    Geometry shader – receives as its input complete primitives as a collection of vertices, and these i ...

  2. Segmentation fault(core dumped) 调试

    ReadingList: https://mytechrants.wordpress.com/2009/05/22/debugging-a-segmentation-fault-using-gdb/ ...

  3. C++继承:公有,私有,保护(转)

    公有继承(public).私有继承(private).保护继承(protected)是常用的三种继承方式. 1. 公有继承(public) 公有继承的特点是基类的公有成员和保护成员作为派生类的成员时, ...

  4. CUDA编程-&gt;CUDA入门了解(一)

    安装好CUDA6.5+VS2012,操作系统为Win8.1版本号,首先下个GPU-Z检測了一下: 看出本显卡属于中低端配置.关键看两个: Shaders=384.也称作SM.或者说core/流处理器数 ...

  5. SDP, RTP, RTCP, RTSP, RTMP 名词解释

    读维基百科里的词条,记录的一点笔记. SDP 会话描述协议 Session Description Protocol 严格来说 SDP 不是一种协议,而是一种格式约定,用于描述流媒体的参数.如协商媒体 ...

  6. iOS 浅赋值、深复制、全然复制的知识点梳理验证(附加归档解档)

    写于前: 在之前转载的一片文章中.文中对浅复制和深复制进行了具体的解读,同一时候还提到了深复制(one-level-deep copy).全然复制(true copy)的概念,并指出iOS开发中的深复 ...

  7. HDU5363:Key Set

    Problem Description soda has a set S with n integers {1,2,-,n}. A set is called key set if the sum o ...

  8. Spring Data MongoDB 四:基本文档改动(update)(一)

    Spring Data MongoDB 三:基本文档查询(Query.BasicQuery)(一) 学习MongoDB 二:MongoDB加入.删除.改动 一.简单介绍 Spring Data  Mo ...

  9. 【BZOJ2338】[HNOI2011]数矩形 几何

    [BZOJ2338][HNOI2011]数矩形 题解:比较直观的做法就是枚举对角线,两个对角线能构成矩形当且仅当它们的长度和中点相同,然后用到结论:n个点构成的矩形不超过n^2.5个(不会证),所以两 ...

  10. EasyIPCamera实现Windows PC桌面、安卓Android桌面同屏直播,助力无纸化会议系统

    最近在EasyDarwin开源群里,有不少用户私信需求,要做一种能够多端同屏的系统,细分下来有屏幕采集端和同屏端,屏幕采集端细想也就是一个低延时的流媒体音视频服务器,同屏端也就是一个低延时的播放器,负 ...