SpringBoot连接数据库的时候报错

java.sql.SQLException: The server time zone value 'PDT' 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) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar:na]
......
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'PDT' 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_181]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_181]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2241) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2265) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825) ~[mysql-connector-java-8.0.15.jar:8.0.15]
... 99 common frames omitted

  解决方案如下

    可以检查数据库版本和驱动的包是否适配,如果是mysql 8以上的版本,则需要驱动程序的版本与UTC时区配合使用,在JDBC连接中必须在连接字符串中明确指定serverTimezone。例如:

spring.datasource.url=jdbc:mysql://192.168.2.129:3306/test_db?useJDBCCompliantTimezoneShift=true&serverTimezone=UTC

com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'PDT' is.......的更多相关文章

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

    一.问题 今天用mybatis连接数据库时出现了如下错误: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The serve ...

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

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

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

  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. com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '��� mysql-installer-community-8.0.15.0

    <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> &l ...

随机推荐

  1. 微信、QQ第三方登录授权时的问题总结

    一.微信第一个问题:redirect_uri域名与后台配置不一致,错误码:10003 解决方案: 1,首先确定访问的第三方接口地址参数前后顺序是否正确,redirect_uri回调地址是否加了http ...

  2. Python2.x与Python3.x的主要区别(转)

    python2.x和python3.x版本有很大的差异,除了依赖包的名称变化很大外,其主要差异总结如下: 1)print函数 Python3中,print函数的括号是必须的,Python2是可选的. ...

  3. Point-wise Mutual Information

    Point-wise Mutual Information (Yao, et al 2019) reclaimed a clear description of Point-wise Mutual I ...

  4. Ubuntu系统下各种报错杂烩(持续更新)

    在Github时报Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hos ...

  5. easyui tree checkbox 单选控制

    参考文档:中文网:http://www.jeasyui.net/plugins/185.html easyui-tree的checkbox默认是多选的, 如何控制只能单选一个子节点,看代码: $('# ...

  6. 【汇总】PHP 伪协议 利用

    日期:2019-07-28 21:24:36 更新: 作者:Bay0net 介绍: 0x01.基本信息 文件包含函数 include() require() include_once() requir ...

  7. django 如何传递id 参数

    urls.py  注意这里的bid

  8. harbor无法登陆解决

    添加如下内容 [root@bogon ~]# vi /etc/docker/daemon.json { "registry-mirrors": ["https://wb2 ...

  9. Kafka sender消息生产者

    1.pom文件引入Kafka依赖(我用的版本是2.2.2.RELEASE) <dependency> <groupId>org.springframework.kafka< ...

  10. H3C版本升级

    H3C S5500和S3100都可以通过TFTP方式进行升级,1.设置交换机的vlan1的ip地址,如10.10.10.2/242.设置电脑和交换机连接的ip地址,如10.10.10.1/243.在交 ...