mysql数据库The server time zone value '�й���׼ʱ��' is unrecogni等报错解决_程序媛乐园-程序员宅基地

技术标签: MySql学习  SpringBoot学习  The server time zone value '�й���׼ʱ  MyBatis学习  Mysql报错解决  

MySQL连接报错

spring.datasource.url连接信息出问题。

报错信息

{
  "timestamp": "2019-11-12T11:07:30.870+0000",
  "status": 500,
  "error": "Internal Server Error",
  "message": "nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n### The error may exist in file [E:\\eclipse\\workspace\\cms_jd1911\\target\\classes\\mapper\\UserMapper.xml]\r\n### The error may involve com.briup.dao.UserMapper.selectByExample\r\n### The error occurred while executing a query\r\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.",
  "trace": "org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n### The error may exist in file [E:\\eclipse\\workspace\\cms_jd1911\\target\\classes\\mapper\\UserMapper.xml]\r\n### The error may involve com.briup.dao.UserMapper.selectByExample\r\n### The error occurred while executing a query\r\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n\tat org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)\r\n\tat org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)\r\n\tat com.sun.proxy.$Proxy75.selectList(Unknown Source)\r\n\tat org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)\r\n\tat org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)\r\n\tat org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)\r\n\tat org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:93)\r\n\tat com.sun.proxy.$Proxy76.selectByExample(Unknown Source)\r\n\tat com.briup.service.impl.UserImpl.findAll(UserImpl.java:30)\r\n\tat com.briup.web.controller.TestController.findAll(TestController.java:28)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n\tat java.lang.reflect.Method.invoke(Unknown Source)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)\r\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:634)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\r\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\r\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\r\n\tat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\r\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\r\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)\r\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)\r\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)\r\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.lang.Thread.run(Unknown Source)\r\nCaused by: org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n### The error may exist in file [E:\\eclipse\\workspace\\cms_jd1911\\target\\classes\\mapper\\UserMapper.xml]\r\n### The error may involve com.briup.dao.UserMapper.selectByExample\r\n### The error occurred while executing a query\r\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n\tat org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)\r\n\tat org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)\r\n\tat org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n\tat java.lang.reflect.Method.invoke(Unknown Source)\r\n\tat org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)\r\n\t... 58 more\r\nCaused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n\tat org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)\r\n\tat org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)\r\n\tat org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)\r\n\tat org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)\r\n\tat org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)\r\n\tat org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)\r\n\tat org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)\r\n\tat org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)\r\n\tat org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)\r\n\tat org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)\r\n\tat org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)\r\n\t... 64 more\r\nCaused by: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)\r\n\tat com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:906)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:831)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)\r\n\tat com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)\r\n\tat com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)\r\n\tat com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:353)\r\n\tat com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)\r\n\tat com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)\r\n\tat com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:562)\r\n\tat com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)\r\n\tat com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)\r\n\tat org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)\r\n\tat org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)\r\n\tat org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)\r\n\t... 74 more\r\nCaused 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.\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\r\n\tat sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)\r\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)\r\n\tat java.lang.reflect.Constructor.newInstance(Unknown Source)\r\n\tat com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)\r\n\tat com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)\r\n\tat com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)\r\n\tat com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2121)\r\n\tat com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2145)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)\r\n\tat com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:869)\r\n\t... 88 more\r\n",
  "path": "/test/findAll"
}

在这里插入图片描述

出现问题的原因

spring.datasource.url连接时设置出错。

解决方法

在数据库后方加入如下代码。
在这里插入图片描述

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/cmsjd1911?serverTimezone=UTC&useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8

解决结果

问题已解决。数据正常显示。
在这里插入图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_41306364/article/details/103036491

智能推荐

c#保存文件的一个自定义方法_七微月的博客-程序员宅基地

代码: /// /// 写入文件追加 /// /// /// public static void WriteLineAdd(string message, string filePath) { string file = "";

温湿度传感器dht11的lcd显示[嵌入式系统]_weixin_30907523的博客-程序员宅基地

夏任务105:做一个桌面温湿度计http://www.cnblogs.com/zxRPI/archive/2013/03/03/2941303.html实验要求用RPi采集温度、湿度和气压传感器的数据,在LCD显示实验工具:Raspberry Pi Model B主机,8G c10 SD卡,pl2303...

区块链征信重构现有征信模式_跨链技术践行者的博客-程序员宅基地

征信市场规模未来超1000亿平安证券发表报告称中国征信行业未来市场规模将达千亿;而美国富国银行预计,中国个人征信市场规模超2000亿。不管未来市场是否达到这个规模,但有一点是肯定的,征信市场空间巨大,但目前整个行业被划成一个个孤岛,信息不能共享,不能充分挖掘数据蕴藏的价值。征信行业面临核心难题目前征信行业面临核心难题:不想共享自己数据,却需要获取第三方数据,传统技术架构解决不了这个问题...

大数据调度工具oozie详细介绍_chihuagou0225的博客-程序员宅基地

背景之前项目中的sqoop等离线数据迁移job都是利用shell脚本通过crontab进行定时执行,这样实现的话比较简单,但是随着多个job复杂度的提升,无论是协调工作还是任务监控都变得麻烦,我们选择使用oozie来对工作流进行调度监控。一、官网介绍首先看官网首页介绍:http://oo...

UnknownServiceException: CLEARTEXT communication to XXX not permitted by network security policy_胖虎1的博客-程序员宅基地

使用高版本的OkHttp在进行http请求时会报出这个错误,https则不会。解决办法1.打开AndroidManifest.xml 文件,在 application 元素中添加:android:usesCleartextTraffic=”true”2.在res下新建一个xml目录 创建名为network_security_config.xml 文件 &amp;lt;?xml vers...

常用软件啊_m0_62482223的博客-程序员宅基地

钉钉——沟通交流office办公软件——熟练编写文档,PPT和数据统计有道词典——在线词典,解决代码中单词问题印象笔记——在线记录个人笔记思维导图——保存和分想思路鲁大师——系统工具软件,检测硬件notepad++——文本编辑器fscapture——截图工具kk录像机——录屏工具火绒——安全软件CSDN:专业开发者社区 https://blog.csdn.net/ 全球知名中文IT技术交流平台...

随便推点

MSP430FW428时钟树原理_yuchendoudou的博客-程序员宅基地

MSP430FW428时钟树原理1,2,4相当于锁相环,通过晶振产生的精准ACLK时钟来作为校准输入,DC Generator与DCO组成振荡器,来产生不精确的频率f(DCO),然后经过(4),再经过 /(N+1)后分频为fDCO的1/(D*(N+1))后输入1,经过多次循环即可使得锁相环路基准频率输入与多次分频后输入频率几乎相等,然后即可输出精准震荡频率fDCO,其值为ACLK的D*(N+1...

linux下安装mysql8.0_往日时光--的博客-程序员宅基地

一、下载mysql安装包网易云镜像开源站搜索 : mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar二、安装mysql#进入usr下的local目录cd /usr/local#创建mysql目录 把刚才下载的上传到这个目录 mkdir mysql#解压刚才上传的这个 tar包tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar#安装mysql 依次执行以下操作rpm -ivh mysql-communi

java 用List存储对象操作(实例讲解)_红狼大大的博客-程序员宅基地_java 静态list对象

一.List包的引入import java.util.List;import java.util.ArrayList;注:如果用提示(灯泡)引入的包,一定要注意是util中的,有可能错误的自动引入了java.awt.List,那么在初始化的时候会显示错误。如:List Books=new ArrayList(); 会提示你 “类型List不带有参数”,一定要注意这个小细节。二.图书馆实例...

【web基础】CSS选择器_徐长亮的博客-程序员宅基地

1.1元素选择器以html标签的名称p/h1{}input元素中,文本框,单选框等都一个样式1.2类选择器,不同的标签细分;css文件中: .s1{..}html页面中: <元素 class=”s1”>缺点:文本框的使用难题

Logistic回归_aiqituo9030的博客-程序员宅基地

目录 什么是Logistic回归 为什么叫对数几率函数 损失函数/优化目标 优化算法 正则化 参考资料台湾大学《机器学习技法》视频李航《统计学习方法》深入浅出ML之Regression家族Logistic Regression Th...

推荐文章

热门文章

相关标签