栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【问题解决】Cause: java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized or repres

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【问题解决】Cause: java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized or repres

文章目录
  • 问题描述:
  • 报错原因:
  • 解决办法:
  • 报错日志:

问题描述:

Cause: 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.

持久化异常原因:java.sql.SQLException:服务器时区值’ й׼ʱ’无法识别或代表多个时区。 如果希望利用时区支持,则必须(通过serverTimezone配置属性)配置服务器或JDBC驱动程序,以使用更特定的时区值。

报错原因:

这是jdbc连接url路径里面没有加时区;

解决办法:

mybatis.config.xml文件中url加入:

serverTimezone=Asia/Shanghai


    
    
    
    
    

报错日志:
"D:Program FilesJavajdk1.8.0_261binjava.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:Program FilesIntelliJ IDEA 2020.2.1libidea_rt.jar=14117:D:Program FilesIntelliJ IDEA 2020.2.1bin" -Dfile.encoding=UTF-8 -classpath "D:Program FilesIntelliJ IDEA 2020.2.1libidea_rt.jar;D:Program FilesIntelliJ IDEA 2020.2.1pluginsjunitlibjunit5-rt.jar;D:Program FilesIntelliJ IDEA 2020.2.1pluginsjunitlibjunit-rt.jar;D:Program FilesJavajdk1.8.0_261jrelibcharsets.jar;D:Program FilesJavajdk1.8.0_261jrelibdeploy.jar;D:Program FilesJavajdk1.8.0_261jrelibextaccess-bridge-64.jar;D:Program FilesJavajdk1.8.0_261jrelibextcldrdata.jar;D:Program FilesJavajdk1.8.0_261jrelibextdnsns.jar;D:Program FilesJavajdk1.8.0_261jrelibextjaccess.jar;D:Program FilesJavajdk1.8.0_261jrelibextjfxrt.jar;D:Program FilesJavajdk1.8.0_261jrelibextlocaledata.jar;D:Program FilesJavajdk1.8.0_261jrelibextnashorn.jar;D:Program FilesJavajdk1.8.0_261jrelibextsunec.jar;D:Program FilesJavajdk1.8.0_261jrelibextsunjce_provider.jar;D:Program FilesJavajdk1.8.0_261jrelibextsunmscapi.jar;D:Program FilesJavajdk1.8.0_261jrelibextsunpkcs11.jar;D:Program FilesJavajdk1.8.0_261jrelibextzipfs.jar;D:Program FilesJavajdk1.8.0_261jrelibjavaws.jar;D:Program FilesJavajdk1.8.0_261jrelibjce.jar;D:Program FilesJavajdk1.8.0_261jrelibjfr.jar;D:Program FilesJavajdk1.8.0_261jrelibjfxswt.jar;D:Program FilesJavajdk1.8.0_261jrelibjsse.jar;D:Program FilesJavajdk1.8.0_261jrelibmanagement-agent.jar;D:Program FilesJavajdk1.8.0_261jrelibplugin.jar;D:Program FilesJavajdk1.8.0_261jrelibresources.jar;D:Program FilesJavajdk1.8.0_261jrelibrt.jar;D:IdeaProjectsMyBatis-Studymybatis-01targettest-classes;D:IdeaProjectsMyBatis-Studymybatis-01targetclasses;D:Program FilesmavenRepositorymysqlmysql-connector-java8.0.16mysql-connector-java-8.0.16.jar;D:Program FilesmavenRepositorycomgoogleprotobufprotobuf-java3.6.1protobuf-java-3.6.1.jar;D:Program FilesmavenRepositoryorgmybatismybatis3.4.2mybatis-3.4.2.jar;D:Program FilesmavenRepositoryjunitjunit4.11junit-4.11.jar;D:Program FilesmavenRepositoryorghamcresthamcrest-core1.3hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.kuang.dao.UserDaoTest,test

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: 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.
### The error may exist in com/kuang/dao/UserMapper.xml
### The error may involve com.kuang.dao.UserDao.getUserList
### The error occurred while executing a query
### Cause: 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 org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy2.getUserList(Unknown Source)
	at com.kuang.dao.UserDaoTest.test(UserDaoTest.java:43)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: 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:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
	at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:455)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
	at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
	at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
	at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
	at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
	at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:138)
	at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:60)
	at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
	... 28 more
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(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.NativeProtocol.configureTimezone(NativeProtocol.java:2243)
	at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2267)
	at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
	... 48 more


Process finished with exit code -1

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1027653.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号