因为换了个电脑用,运行时报了个很少见的异常。如下:

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. 异常

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

异常

看着不像是sql的问题,检查了下代码,发现也没明显啥问题,就去查了下。

果然有遇到相同问题的,

1的异常是因为所用的Mysql驱动包已经不推荐之前用的mysql驱动类,推荐使用新的mysql驱动类

2的异常是因为mysql时区问题

  就是上面标红的SQL异常,我们需要在数据库 URL中设置serverTimezone属性:

static final String DB_URL = "jdbc:mysql://localhost:3306/RUNOOB" +"?serverTimezone=GMT%2B8";这里的 GMT%2B8 代表是东八区。

当然有更好的办法就是win + R进入cmd窗口,mysql -u root -p 进入mysql ,然后输入 set  global time_zone = '+8:00';

尴尬的是登陆时提示没用mysql命令,果然环境变量中path路径中需要添加mysql的bin目录路径。

然后重新执行下上述命令即可。

The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized 偶然遇到的mysql时区问题相关推荐

  1. The server time zone value is unrecognized or repr

    异常信息: The server time zone value is unrecognized or represents more than one time zone. You must con ...

  2. JDBC告警系列(一)The server time zone value 'ÖÐ' is unrecognized or represents more than one time zone....

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

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

    场景 运行Mybatis的generator自动生成代码时提示: caused by :The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognize ...

  4. 解决Hibernate报错The server time zone value is unrecognized or represents more than one time zone

    解决Hibernate报错The server time zone value is unrecognized or represents more than one time zone   笔者在使 ...

  5. MySQL小问题:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents...

    这是因为时区设置不对 问题背景: 在运行storm项目,进行页面显示的时候,报错: java.sql.SQLException: The server time zone value 'Öйú±ê× ...

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

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

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

    Spring Cloud启动jdbc报错 1.Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The s ...

  8. JDBC编程可能遇到的错误:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or ..

    文章目录 1.错误提示: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 2.提示:Loading class com.mysql.jd ...

  9. SQLException:The server time zone value is unrecognized

    问题:SQLException:The server time zone value is unrecognized 分析:springboot从2.4.2及之前的版本配合mysql8.0+的驱动,需 ...

最新文章

  1. 8 -- 深入使用Spring -- 3...1 Resource实现类InputStreamResource、ByteArrayResource
  2. 昌平房价已降至6500元每一平米
  3. Spark 与MapReduce 资源调度方面的简单对比
  4. C语言求数组中的最大值
  5. Spring与SpringMVC集成出现的问题
  6. 40个新鲜出炉的 jQuery 插件和免费教程【上篇】 转载自:梦想天空
  7. form表单提交数据的同时上传文件代码示例
  8. 编译优化之 - 常量传播入门
  9. ubuntu16.04安装caffe
  10. 细胞工程1、2-实验室组成与无菌操作
  11. 网恋背后的骗局:那些被宰杀掉的猪!必看!
  12. JavaScript随手笔记之--html拼接语句传递json数据
  13. 曽有望登顶互联网的它,留下“遗产”消失不见
  14. 您试图在此 Web 服务器上访问的 Web 应用程序当前不可用。
  15. RVV线与RV线有什么区别
  16. Python网站导航项目-2.项目创建与环境配置
  17. Wampserver部署thinksns
  18. python基础训练 day8
  19. 在linux下怎么打包直接运行的node-webkit桌面应用
  20. 软件工程期末复习总结

热门文章

  1. 基础练习 FJ的字符串 递推 C++
  2. java各个版本的特性_Java各个版本的新特性
  3. 百度-Java中级面试题分享-
  4. 基于javaweb(springboot+mybatis)网上酒类商城项目设计和实现以及文档报告
  5. Tomcat端口号的修改
  6. css的属性是变量是怎么表达,CSS自定义变量属性——像less,sass那样在css中使用变量(译)...
  7. mysql连接不上远程数据库_Mysql 连接不上远程数据库,求助
  8. php调用restful接口_分享一个PHP调用RestFul接口的函数
  9. java反编译工具_Java开发必会的反编译知识(附支持对Lambda进行反编译的工具)...
  10. Brief C Programs of the Bombs