返回顶部

关于数据库配置时区问题

运行代码时,报如下错误

ERROR com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException - HikariPool-1 - Exception during pool initialization.
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.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)

 该报错是因为.yml配置文件中url处未添加时区参数导致的

 解决:

将url地址处加入参数 &serverTimezone=Asia/Shanghai 即可解决,如下所示

url: jdbc:mysql://localhost:3306/company?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
posted @ 2023-08-22 10:11  MoreTryHarder  阅读(130)  评论(0)    收藏  举报