java连接数据库8.0.12是出现时区错误

连接mysql8.0.12是报“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 utili”这样的错误。

这是时区错误,在书写的url中加这样一句就可以了“?serverTimezone=GMT%2B8”

例如我的代码修正前是“String url = “jdbc:mysql://127.0.0.1:3306
/csdndb?useSSL=FALSE&Timezone=UTC”;”

修正后是“String url=”jdbc:mysql://127.0.0.1:3306/csdndb?serverTimezone=GMT%2B8&useSSL=FALSE&Timezone=UTC”;”

猜你喜欢

转载自blog.csdn.net/weixin_42428357/article/details/81985408
今日推荐