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. Service 层实现

    一.实验介绍 1.1 实验内容 本节课程主要利用 Spring 框架实现 Service 层. 1.2 实验知识点 Spring 框架 1.3 实验环境 JDK1.8 Eclipse JavaEE 二 ...

  2. Android——滑动事件冲突解决

    android中的事件类型分为按键事件和屏幕触摸事件,Touch事件是屏幕触摸事件的基础事件. android系统中的每个View的子类都具有下面三个与TouchEvent处理密切相关的方法: (1) ...

  3. 小数运算需要注意什么? 接口和抽象类 WinForm窗体上两个panel,怎么实现一个panel固定漂浮在另一个panel之上

    小数运算需要注意什么? 1. 生活中0.1+0.2=0.3, 计算机中可不是这样,为什么呢? 大家都知道计算机类型都是有数据范围的.整形int范围是 正负21亿左右,小数类型同样也是有范围的,但是即使 ...

  4. 【HDOJ 5371】 Hotaru&#39;s problem

    [HDOJ 5371] Hotaru's problem Manacher算法+穷举/set Manacher算法一好文:http://blog.csdn.net/yzl_rex/article/de ...

  5. HDMI速率计算

    我们在采集HDMI口的数据时,首先肯定要计算它的速率是多少.怎么计算这个速率,本文要跟大家分享的便是这个事情. HDMI口有三个TM-DS(Time Minimized Differential Si ...

  6. professional cuda c programming--CUDA库简单介绍

    CUDA Libraries简单介绍   上图是CUDA 库的位置.本文简要介绍cuSPARSE.cuBLAS.cuFFT和cuRAND.之后会介绍OpenACC. cuSPARSE线性代数库,主要针 ...

  7. hdu5318 The Goddess Of The Moon (矩阵高速幂优化dp)

    题目:pid=5318">http://acm.hdu.edu.cn/showproblem.php?pid=5318 题意:给定n个数字串和整数m,规定若数字串s1的后缀和数字串s2 ...

  8. 设置Ubuntu 16.04 LTS的Unity启动器的位置命令

    将Ubuntu 16.04 LTS的Unity启动器移动到桌面底部命令:gsettings set com.canonical.Unity.Launcher launcher-position Bot ...

  9. 深度解析开发项目之 03 - enum的使用

    深度解析开发项目之 03 - enum的使用 01 - 在#import和@interface之间定义typedef enum 注意: 默认是0,1,2,3 02 - 定义可以操作的数据类型的属性 0 ...

  10. java通过http方式下载文件

    package com.qiyi; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...