org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain 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.
出现mysql错误时候,org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException:
上面为标配,所有错误提示前面都是这句,具体错误原因在其后面,出现这种错误的原因是现在mysql版本较高,对于设置url时候,可以设置一些列参数,但是必须设置时区参数
serverTimezone=UTC //UTC表示国际时间,也可以设置其他地区的时间,
所以设置好应该是下面这种
"jdbc:mysql://localhost:3306/denglu?useUnicode=true&serverTimezone=UTC"
用&表示和的意思,可以设置多个参数,用&隔开就好了,但是高版本的Mysql必须要设置区时的参数,不设置就会出现上面报错,其他设不设置无妨。
下面文章是url参数的种类和代表的具体意义
本文详细解析了在使用高版本MySQL时,由于未正确设置时区参数导致的org.springframework.jdbc.CannotGetJdbcConnectionException异常。介绍了如何通过在JDBC连接字符串中添加serverTimezone参数来解决这一问题,确保应用程序能正确读取和处理数据库中的时间数据。
1048

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



