龙空技术网

mysql 连接驱动问题

远观山川近看海 173

前言:

而今咱们对“mysql连接问题”大致比较注重,小伙伴们都想要知道一些“mysql连接问题”的相关内容。那么小编在网上收集了一些对于“mysql连接问题””的相关资讯,希望你们能喜欢,咱们一起来了解一下吧!

问题:
You must configure either the server or JDBC driver (via the serverTimezone configuration property)

'�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration

解决方案:

错误提示:

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is 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 specifc time zone value if you want to utilize time zone support.

解决办法;

在连接字符串后面加上?serverTimezone=UTC

其中UTC是统一标准世界时间。

完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC

或者还有另一种选择:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,这个是解决中文乱码输入问题,当然也可以和上面的一起结合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC


标签: #mysql连接问题