使用最新的连接驱动
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>6.0.3</version> </dependency>
运行程序时抛出异常:
Caused by: 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.
解决办法:
在
jdbcUrl=jdbc:mysql://localhost:3306/spring
后面加上:
jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC
但如果你的jdbcUrl类似下面:
jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC&characterEncoding=utf-8
就是有多个params的时候需要以&分开,但&要改为& 如下:
jdbcUrl=jdbc:mysql://localhost:3306/spring?serverTimezone=UTC&characterEncoding=utf-8
一别两宽 各生欢喜
本文介绍了一种常见的MySQL连接异常问题,即服务器返回的时区不被JDBC驱动识别。文章提供了具体的解决方案,包括如何正确配置JDBC连接字符串以避免此类错误。
1136

被折叠的 条评论
为什么被折叠?



