springBoot连接数据库错误: The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more..

作者:

测试springboot连接数据库操作时,出现了一下错误

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 specific 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.22.jar:8.0.22] at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.22.jar:8.0.22] ...

原本以为是Jdbc Driver错误,查看也没有配置错误,搞了半天异常信息的乱码也没有解决,最后发现有一个单词出现“serverTimezone”,忽然想起来好像是mysql驱动高版本之后,在连接数据库的信息上要加上这个配置,不然出错,果然,配上之后,错误解决,记录一下,老是忘记。

连接数据库的完整信息:

jdbc:mysql://127.0.0.1:3306/xxx?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC

乱码问题解决了再来填…

the end

免责声明:本文内容均来自互联网,但不代表简明教程的观点和立场.

已有 7503 次赞