出错场景:

使用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

相关文章:

  • 2021-08-09
  • 2021-08-31
  • 2021-05-19
  • 2021-10-19
  • 2021-09-01
  • 2021-12-12
  • 2021-04-21
  • 2021-03-26
猜你喜欢
  • 2021-05-04
  • 2021-08-11
  • 2022-12-23
  • 2021-08-19
  • 2021-08-28
  • 2021-10-30
  • 2021-12-13
相关资源
相似解决方案