//第一个异常

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

意思是 mysqljdbc . driver被弃用了新的驱动类是“com.mysql.cjdbc.driver”。驱动程序通过SPI自动注册,而手动加载类通常是不必要的,解决方案如下:

//解决方法
把com.mysql.jdbc.Driver 改为com.mysql.cj.jdbc.Driver 即可

//第二个异常

java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time

提示系统时区出现错误,可以在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; 代替。

java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ 解决方案的更多相关文章

  1. MySQL连接数据库报时区错误:java.sql.SQLException: The server time zone value

    连接MySQL数据库时报以下时区错误信息: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized ...

  2. 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized...解决方法

    今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or r ...

  3. MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???׼ʱ?' is unrecognized or represents more than one time zone.

    JDBC访问MySql异常 Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException ...

  4. 【JDBC】java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

    在使用阿里的druid 时,报了一个异常java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized ...

  5. 解决java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone

    使用spring boot整合MySQL时一直报 java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecog ...

  6. JDBC连接数据库报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ......

    问题:Java程序使用JDBC连接MySQL数据库时,控制台报错如下: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' ...

  7. Exception in thread “main” java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone.

    Exception in thread “main” java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’ is unrecogn ...

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

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

  9. 【MySQL】java.sql.SQLException: The server time zone value

    错误:Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: The se ...

随机推荐

  1. php代码审计8审计文件上传漏洞

    文件上传漏洞是指用户上传了一个可执行的脚步文件,并通过此脚本文件获得了执行服务器端命令的能力,这种攻击方式是最直接和有效的,文件上传本身是没问题的,有问题的是文件上传后,服务器怎么处理,解释文件,通过 ...

  2. 【微服务】之七:轻松搞定SpringCloud微服务-API权限控制

    权限控制,是一个系统当中必须的重要功能.张三只能访问输入张三的特定功能,李四不能访问属于赵六的特定菜单.这就要求对整个体系做一个完善的权限控制体系.该体系应该具备针区分用户.权限.角色等各种必须的功能 ...

  3. Spark JavaRDD、JavaPairRDD、Dataset之间的相互转换

    主要内容: 1. JavaRDD to JavaPairRDD 2. Dataset to JavaPairRDD 3. JavaPairRDD to JavaRDD 4. JavaRDD to Da ...

  4. JDBC_时间处理_Date_Time_Timestamp区别_随机日期生成

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement;import ...

  5. WinForm中如何实现在容器控件中嵌入form窗体(panel与子窗体)

    今天在做项目时候遇到一个问题,窗体分为左右两部分,要求在左边栏点击按钮时,右边动态加载窗体最后想到用panel实现,经历几次失败,并查找资料后,终于搞定 说明:如果多次切换需加入 panel.clea ...

  6. What Goes Up UVA - 481 LIS+打印路径 【模板】

    打印严格上升子序列: #include<iostream> #include<cstdio> #include<algorithm> #include<cst ...

  7. How to: Create a Business Model in the XPO Data Model Designer

    How to: Create a Business Model in the XPO Data Model Designer This topic provides step-by-step inst ...

  8. bootstrap的其他

    情境文本颜色 <p class="text-muted">...</p> <p class="text-primary">. ...

  9. C++_友元2-友元成员函数

    接着上一篇<友元是什么>中,我们发现Remote友元类的大多数方法都是用Tv类的公有接口实现.这意味着这些方法并不是真正需要友元. 事实上唯一直接访问Tv成员的Remote方法是Remot ...

  10. 【贪心】洛谷P1607 [USACO09FEB]庙会班车Fair Shuttle 题解

        不是很容易写出正解的贪心问题. 题目描述 Although Farmer John has no problems walking around the fair to collect pri ...