java.sql.SQLException异常

新版数据库驱动链接异常

java.sql.SQLException: The server time zone value 'EDT' 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.java

  • 使用的数据库是MySQL,驱动是8.0.16。这是因为新版数据库驱动链接程序须要指定UTC时区所形成的,在jdbc链接的url后面加上serverTimezone=GMT便可解决问题,若是须要使用gmt+8时区,须要写成GMT%2B8,不然会被解析为空。 再一个解决办法就是使用低版本的MySQL jdbc驱动,5.1.28不会存在时区的问题。

修改后:mysql

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/wljkzx?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=123
相关文章
相关标签/搜索