老师,这个错误怎么解决?

老师,这个错误怎么解决?

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

Fri May 08 18:30:21 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

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:127)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)

at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at com.imooc.jdbc.demo1.JDBCDemo1.demo1(JDBCDemo1.java:25)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

Caused by: 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(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83)

at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:128)

at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2201)

at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2225)

at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1391)

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:993)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)

... 29 more


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小脸 2020-05-08 19:03:24

同学你好,根据报错信息:

http://img1.sycdn.imooc.com//climg/5eb53c51090aaf1107970220.jpg不能正确识别时区,建议同学在连接数据库时,添加serverTimezone的时区设置,并且为了避免乱码等问题,同学可以加上CharacterEncoding等编码内容的设置,比如:

数据库名?serverTimezone=Hongkong&useUnicode=true&characterEncoding=utf-8&useSSL=false

祝学习愉快~

  • 提问者 慕沐8150141 #1
    老师,还是不能解决,我用的是MYSQL8.0,会不会是版本的问题?
    2020-05-08 19:21:58
  • 好帮手慕柯南 回复 提问者 慕沐8150141 #2
    同学你好! 你的报错是时区问题,通过制定时区是可以解决的。请问同学目前的报错是否和之前一样呢。 如果一样,建议你贴一下你数据库连接的配置 如果不一样,建议你贴一下最新的错误信息。 祝学习愉快~
    2020-05-09 09:43:19
  • 提问者 慕沐8150141 回复 好帮手慕柯南 #3
    一样的错误 连接配置 Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctest?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT","root","root");
    2020-05-09 18:38:55
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师