今天尝试数据库,代码确实没问题就是给了给这个东西

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.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at db.Prepare.main(Prepare.java:22)

后来在大佬们的帮助下得知

数据库时区设置错误。

解决方法:分两种,但原理都是时区设置为当前系统时区

1、在连接数据库语句中的url变量中修改

Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/t_user","root","root");//修改前
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/t_user?serverTimezone=GMT%2B8","root","root");//修改后

2、使用root用户登录mysql,执行以下语句

set global time_zone=’+8:00’;

提示Query OK…即为成功。

JDBC获取连接抛出java.sql.SQLException: The server time zone...的更多相关文章

  1. 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 'Öйú±ê׼ʱ¼ä' ...

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

    SpringBoot运行报错——java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or rep ...

  4. 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 server

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

  5. 【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 ...

  6. spring boot启动异常: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

    项目启动时提示:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represen ...

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

    报错内容: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents mo ...

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

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

  9. 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 ...

随机推荐

  1. 基于JWT实现token验证

    JWT的介绍 Json Web Token(JWT)是目前比较流行的跨域认证解决方案,是一种基于JSON的开发标准,由于数据是可以经过签名加密的,比较安全可靠,一般用于前端和服务器之间传递信息,也可以 ...

  2. 从零搭建Spring Cloud Gateway网关(一)

    新建Spring Boot项目 怎么新建Spring Boot项目这里不再具体赘述,不会的可以翻看下之前的博客或者直接百度.这里直接贴出对应的pom文件. pom依赖如下: <?xml vers ...

  3. Go 武林外传 - 初出茅庐

    没有旁白. 我叫小白, 白痴的白. 老头说我太笨了, 提前放我下山, 让我自生自灭. 对了, 忘了说了, 那老头是我师傅. 虽然我的内心深处是拒绝的, 但是我又打不过老头, 只好收拾铺盖滚犊子了. 算 ...

  4. 【spring springmvc】springmvc使用注解声明控制器与请求映射

    目录 概述 壹:注解说明 贰:实现注解声明控制器与请求映射 一:使用controller 二:配置包扫描与视图解析器 1.配置包扫描 2.配置试图解析器 三:配置部署描述符 1.读取spring-mv ...

  5. 量化学习 | Tushare 基本面选股 (二)

    量化投资比较重要的是策略,可是你得先选个好股,价值投资需要认同他的价值,值得投资的股票才有投资的机会,现在简单介绍一下基于基本面的选股,其实我现实生活中也有炒股,都是经验之说的选股原则. 首先从tus ...

  6. linux入门系列19--数据库管理系统(DBMS)之MariaDB

    前面讲完Linux下一系列服务的配置和使用之后,本文简单介绍一款数据库管理系统(MySQL的兄弟)MariaDB. 如果你有MySQL或其他数据的使用经验,MariaDB使用起来将非常轻松. 本文讲解 ...

  7. Scapy编写ICMP扫描脚本

    使用Scapy模块编写ICMP扫描脚本: from scapy.all import * import optparse import threading import os def scan(ipt ...

  8. 五分钟学后端技术:如何学习Redis、memcache等常用缓存技术

    原创声明 本文作者:黄小斜 转载请务必在文章开头注明出处和作者. 本文思维导图 什么是缓存 计算机中的缓存 做后端开发的同学,想必对缓存都不会陌生了,平时我们可能会使用Redis,MemCache这类 ...

  9. url,解释器,响应器,版本控制,分页

    路由控制 -基本路由写法:咱们一直写的

  10. 洛谷 P5176 公约数 题解

    原题链接 我天哪 大大的庆祝一下: 数论黑题 \(T1\) 达成! 激动地不行 记住套路:乱推 \(\gcd\),欧拉筛模板,然后乱换元,乱换式子,完了整除分块,欧拉筛和前缀和就解决了! \[\sum ...