返回顶部

关于数据库配置时区问题

运行代码时,报如下错误

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 @   MoreTryHarder  阅读(98)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性

点击右上角即可分享
微信分享提示
方寸之间,深不见底啊。