在测试MySQL数据库连接的过程中,产生的问题。(在ssm项目环境下进行测试,使用idea编辑器其):

测试MySQL数据库是否连接成功博客:在spring项目中,测试MySQL数据库是否连接成功_qq_41818544的博客-CSDN博客

报错信息:

Fri May 17 14:55:39 CST 2019
There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLSyntaxErrorException: Identifier name 'netsafe&useunicode=true&characterencoding=utf-8&allowmultiqueries=true&usessl=false' is too long ### The error may exist in com/infosec/netsafess/mapper/UserMapper.java (best guess) ### The error may involve com.infosec.netsafess.mapper.UserMapper.getAllUser ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLSyntaxErrorException: Identifier name 'netsafe&useunicode=true&characterencoding=utf-8&allowmultiqueries=true&usessl=false' is too long
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLSyntaxErrorException: Identifier name 'netsafe&useunicode=true&characterencoding=utf-8&allowmultiqueries=true&usessl=false' is too long
### The error may exist in com/infosec/netsafess/mapper/UserMapper.java (best guess)
### The error may involve com.infosec.netsafess.mapper.UserMapper.getAllUser
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLSyntaxErrorException: Identifier name 'netsafe&useunicode=true&characterencoding=utf-8&allowmultiqueries=true&usessl=false' is too longat org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)at com.sun.proxy.$Proxy60.selectList(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)at com.sun.proxy.$Proxy64.getAllUser(Unknown Source)at com.infosec.netsafess.service.impl.UserServiceImpl.getAllUser(UserServiceImpl.java:19)at com.infosec.netsafess.controller.HelloController.getAllUser(HelloController.java:25)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

启动springboot项目,然后访问数据库,报You must configure either the server or JDBC driver (via the serverTimezone conf)的错误。

原因:

因为安装mysql的时候时区设置的不正确 mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用+8:00格式

使用的数据库是MySQL,从上面图看出SpringBoot2.1在你没有指定MySQL驱动版本的情况下它自动依赖的驱动是8.0.12很高的版本,这是由于数据库和系统时区差异所造成的,在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8,否则会被解析为空。再一个解决办法就是使用低版本的MySQL jdbc驱动,5.1.28不会存在时区的问题。

加上这个  ?serverTimezone=UTC

spring.datasource.url=jdbc:mysql://localhost:3306/blog?serverTimezone=UTC

例如:

ssm的报错问题------You must configure either the server or JDBC driver (via the serverTimezone conf)相关推荐

  1. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property

    spring.datasource.url后加上 ?serverTimezone=UTC jdbc:mysql://localhost:3306/test?serverTimezone=UTC spr ...

  2. IDEA连接Mysql报错: 未找到驱动程序类 ‘com.mysql.cj.jdbc.Driver‘.  Change driver class

    报错详细内容:未找到驱动程序类 'com.mysql.cj.jdbc.Driver'. Change driver class 报错原因:Mysql版本为5.0,找不到com.mysql.cj.jdb ...

  3. 初步搭建微服务应用,报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd

    报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedd If you want an ...

  4. 阿里连接池报错:Failed to configure a DataSource ‘url‘ attribute is not specified and no embedd

    阿里连接池报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedd 明明已经配置数据库连接 ...

  5. 远程连接CentOS的MySQL报错:Can't connect to MySQL server on 'XXX' (13)

    环境: 系统版本: CentOS release 6.5 (Final) 数据库版本: 5.1.73 问题描述: 使用客户端远程登录连接基于CentOS 6.5服务器上的Mysql,报错:Can't ...

  6. 【报错解决】错误代码18456,SQL Server 登录失败

    [报错解决]错误代码18456,SQL Server 登录失败 一.故障原因 二.解决办法 2.1 使用Windows身份认证登录 2.2 windows身份登录后,依次选择:安全性->登录名- ...

  7. Mysql登录报错:Can‘t connect to MySQL server on ‘localhost:3306‘ (10061)

    可能每个人遇到问题的情况不一样,首先打开服务我的是当时登录mysql输完密码就会报错:Can't connect to MySQL server on 'localhost:3306' (10061) ...

  8. 自动化测试 appium 会报错 Could not proxy command to remote server. Original error: Error: socket hang up

    问题描述: 最近使用vivo X21A进行APP自动化测试过程中,发现程序运行过程中突然中断,查看报错信息 Error: socket hang up.appium 自动化测试,运行平台 vivo X ...

  9. 接入谷歌AdSense后浏览器控制台报错:Failed to load resource: the server responded with a status of 403的原因及解决办法、

    本篇文章主要讲解,接入谷歌AdSense后浏览器控制台报错:Failed to load resource: the server responded with a status of 403 ads ...

最新文章

  1. 工业界如何解决NER问题?12个trick,与你分享~
  2. 【转载】Hadoop 2.7.3 和Hbase 1.2.4安装教程
  3. nginx实现防止ddos攻击
  4. robotframework安装包_Robot Framework零基础入门教程
  5. python组合数据类型有哪些_Python学习之组合数据类型
  6. [云炬创业基础笔记]第五章创业计划评估17
  7. 设计模式C++实现(4)——原型模式、模板方法模式
  8. CTF-杂项题-伪加密
  9. 领导再也不会因为模型刷新不出来批评我啦---论IE扩内存(转载)
  10. 安装sql server 2008 management studio时,提示升级VS2008 到 SP1
  11. android发布新版忘记keystore(jks)密码终极解决方案
  12. c++中assert
  13. JavaWeb项目—— 博客系统
  14. cdr添加节点快捷键_【CDR干货】常用cdr快捷键命令汇总,快来收藏!
  15. 计算机维修万用电表使用,万用表的使用方法——图解
  16. 测试小兵成长记:中庸之道
  17. 2022年2月语音合成(TTS)和语音识别(ASR)论文月报
  18. FPGA数字信号处理之乘法器
  19. 公益中国系列活动进社区之 “健康进社区”系列活动
  20. Python3 gevent 报错 RuntimeWarning: greenlet.greenlet size changed

热门文章

  1. python小波特征提取_Python 小波包变换,小波包能量特征提取 代码
  2. 「shell」替代rm,放入回收站
  3. 分布式调用技术 RPC VS REST
  4. 刨根问底——Handler
  5. 订单可视化(智能制造、流程再造、企业信息化) 第三篇 订单可视化定义及目标...
  6. 微信小程序——获取所有资讯接口数据
  7. IOS CALayer
  8. JMeter学习笔记--JMeter监听器
  9. CSS Hack 和向后兼容
  10. (How to)Windows Live Writer插入Latex公式