idea连接mysql数据库报java.lang.RuntimeException: com.mysql.cj.exceptions.InvalidConnectionAttributeExcepti

idea连接mysql数据库报java.lang.RuntimeException: com.mysql.cj.exceptions.InvalidConnectionAttributeExcepti出错场景:使用idea连接mysql(5.2版本)报错:java.lang.RuntimeException:com.mysql.cj.exceptions.InvalidConnectionAttributeException:Theservertimezonevalue’Öйú±ê׼ʱ¼ä’isunrecognizedorrepresentsmoreth…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

出错场景:

使用idea连接mysql(5.2版本)报错:

java.lang.RuntimeException: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
            at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
            at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
            at com.mysql.cj.protocol.a.NativePro… (show balloon)

大概原因:

 JDBC驱动程序的5.2版本与UTC时区配合使用,必须在连接字符串中明确指定serverTimezone。

解决方法:

jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

idea连接mysql数据库报java.lang.RuntimeException: com.mysql.cj.exceptions.InvalidConnectionAttributeExcepti

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/161470.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号