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)
参考博主辣条z的blog的这句话:JDBC驱动程序的5.2版本与UTC时区配合使用,必须在连接字符串中明确指定serverTimezone。
并且使用博主提供的下面这条语句,数据库是可以连得上的。
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
但是,我之前一直是直接连上mysql的,参考博主的blog后,我觉得是mysql驱动的版本问题,所以我就将版本换了一下。
jdbc:mysql://localhost:3306/health然后直接写这样一句,就连接成功了。
我是用的方法就是修改Driver:MySql的版本,将8改成5了。
点击Go to Driver进入修改版本。
照着这个步骤,我就解决了我的问题了。
参考blog:https://blog.csdn.net/q97052252/article/details/89042882