一、问题

今天用mybatis连接数据库时出现了如下错误:

com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.

查看异常可以大概知道是因为服务器的时区(timezone)无法识别或者不止一个导致的,让我们配置数据库或JDBC的时区。

二、解决办法

1.配置jdbc驱动时区,在jdbc连接mysql的url中加上时区:spring.datasource.url=jdbc:mysql://localhost:3306/forum-dev?serverTimezone=GMT%2B8,这种方法比较推荐,一劳永逸。

2.配置数据库:这种方法据网上说,如果重启电脑,那么还是会失效,所以采用第一种即可。

com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. 问题解决方法的更多相关文章

  1. java 连接数据库报错:Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '

    1.解决方法: 报错信息为: Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server ti ...

  2. Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼ä'

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

  3. com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'PDT' is.......

    SpringBoot连接数据库的时候报错 java.sql.SQLException: The server time zone value 'PDT' is unrecognized or repr ...

  4. com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼

    起初这样能短暂解决问题,后来发现每次机器重启了就还是有这样的错误,还是要执行SQL,很麻烦: show variables like '%time_zone%'; select now(); set ...

  5. Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the serv

    z 此问题为时区问题,在 JDBC 的连接 url 部分加上 useSSL=true&serverTimezone=UTC 即可.如图

  6. c3p0连接池:com.mysql.cj.exceptions.InvalidConnectionAttributeException

    1 遇到的错误com.mysql.cj.exceptions.InvalidConnectionAttributeException: 四月 17, 2019 10:21:13 上午 com.mcha ...

  7. Java连接MySql报错—— com.mysql.cj.exceptions.InvalidConnectionAttributeException

    详细报错 java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents mor ...

  8. MyBatis——com.mysql.cj.exceptions.InvalidConnectionAttributeException

    报错信息 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.c ...

  9. SpringBoot报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone

    解决方法: 在数据库连接url配置后边加&serverTimezone=GMT%2B8 例: jdbc:mysql://127.0.0.1:3306/test改为jdbc:mysql://12 ...

随机推荐

  1. Android开机广播和关机广播

    有些时候我们需要我们的程序在系统开机后能自动运行,这个时候我们可以使用Android中的广播机制,编写一个继承BroadcastReceiver的类,接受系统启动关闭广播.代码如下: /** *@au ...

  2. java向文件中添加数据---手动版日志添加

    核心代码为创建多级文件夹创建 //目标文件 File file=new File(filePath); //若不存在即创建文件 if(!file.exists()) { if (!file.getPa ...

  3. AIM Tech Round 3 (Div. 1) (构造,树形dp,费用流,概率dp)

    B. Recover the String 大意: 求构造01字符串使得子序列00,01,10,11的个数恰好为$a_{00},a_{01},a_{10},a_{11}$ 挺简单的构造, 注意到可以通 ...

  4. CentOS7 install apache

    1. yum install httpd 2. config /etc/httpd/conf/httpd.conf <VirtualHost *:80>  ServerName www.l ...

  5. ubuntu系统连接windows系统

    1,首先我们要在ubuntu系统是输入:sudo apt-get install rdesktop 2, 用法: rdesktop[options] server[:port]     .其实我们就可 ...

  6. POJ-1511 Invitation Cards (双向单源最短路)

    Description In the age of television, not many people attend theater performances. Antique Comedians ...

  7. dp练习(3)——棋盘问题

    设有一个n*m的棋盘(2≤n≤50,2≤m≤50),如下图,在棋盘上有一个中国象棋马. 规定: 1)马只能走日字 2)马只能向右跳 问给定起点x1,y1和终点x2,y2,求出马从x1,y1出发到x2, ...

  8. ABAP基础二:ALV基础之ALV的简单编辑

    前两天有个打印需求变更,需要在ALV显示列表中添加两个字段,可编辑,而我自己用的是函数:REUSE_ALV_GRID_DISPLAY_LVC 因为之前做可编辑基本都是固定套路,定义类,画屏幕.... ...

  9. Eclipse偏好设置的导入与导出

    偏好导入:File--->Import

  10. Java容器——Set接口

    1.定义 set中不允许放入重复的元素(元素相同时只取一个).它使用equals()方法进行比较,如果返回true,两个对象的HashCode值也应该相等. 2.方法 TreeSet中常用的方法: b ...