JDBC中The server time zone value '???ú±ê×??±??' is ............. 的错误

在JDBC使用的时候有时候会出现java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents........的错误.

原因:出现这个的原因是因为 mysql返回的时间总是有问题,比实际时间要早8小时。

解决办法:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8

在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8

转载于:https://my.oschina.net/u/4034553/blog/3066110

你可能感兴趣的:(JDBC中The server time zone value '???ú±ê×??±??' is ............. 的错误)