zoukankan      html  css  js  c++  java
  • java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ 解决方案

    //第一个异常

    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; 代替。

  • 相关阅读:
    进程提权小结
    进程工作集WorkingSet (PSAPI 01)
    GetSystemInfo 和 GlobalMemoryStatus获取系统信息,内存信息
    C++11智能指针 share_ptr,unique_ptr,weak_ptr用法
    结构体及类对象的内存对齐
    菱形继承问题和虚继承
    TLS反调试
    获取程序目录,模块路径
    docker install for centos7
    docker镜像与容器概念
  • 原文地址:https://www.cnblogs.com/cn-chy-com/p/10145690.html
Copyright © 2011-2022 走看看