使用德鲁伊连接池时,出现STATUS 500的错误,Exception是java.lang.NullPointerException
查询控制台发现如下错误:
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.
原因是在配置文件中,URL未添加时区。
jdbc8.0连接MySQL时,URL中必须添加时区(代码如下):
url=jdbc:mysql://localhost:3306/userlogin?useUnicode=true&characterEncoding=utf-8&serverTimezone =Asia/Shanghai
当使用Druid连接MySQL数据库时,遇到STATUS500错误,异常信息为java.lang.NullPointerException,原因是URL缺少了时区设置。为解决此问题,需要在jdbc连接URL中添加`serverTimezone`参数,例如:`jdbc:mysql://localhost:3306/userlogin?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai`。确保正确设置时区以避免时间处理异常。
1万+

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



