今天遇到一个错误,运行RankDao.selectById(id)直接给我报错,很不理解

错误信息:

2021-09-22 10:40:58.824 ERROR 8364 --- [nio-8888-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank WHERE id=1' at line 1
### The error may exist in com/brilliantZC/music/dao/MusicRankDao.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=?
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank WHERE id=1' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank WHERE id=1' at line 1] with root cause

一开始各种百度了各种方法,有说

  1. 创建的表中列的值小于实际值而报错
  2. Controllor 层引入的 Service 接口上面忘记写 @Resource 或 @Autowired 注解
  3. Controllor 层调用的方法是 private 私有的,导致分发失败
  4. 检查Mapper接口代码是否符合规范(用的Mybatis-plus自动忽略)

都试过一遍还是不行,于是我拿着错误的sql语句执行

SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=1

依然报错

music> SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=1
[2021-09-22 10:55:58] [42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank WHERE id=1' at line 1

然后我就迷茫了,接着我把查询语句去掉依然报错

SELECT id,song_list_id,consumer_id,score FROM rank

接着百度,看到因为rank是关键字,不能直接当做非关键字用,需要加上``来使用。换上后可执行了

SELECT id,song_list_id,consumer_id,score FROM `rank`

然后我就修改了表名,错误解决!!!

### The error may involve defaultParameterMap ### The error occurred while setting parameters相关推荐

  1. Mysql的避坑---- The error may involve defaultParameterMap #The error occurred while setting parameters

    Mysql的避坑---- Mysql 数据库连接添加  allowMultiQueries=true属性 最近做项目时,发现操作数据库时 sql报错,如下: ### Error updating da ...

  2. mybatis:### The error may involve defaultParameterMap### The error occurred while setting parameter

    完整报错: Caused by: org.apache.ibatis.exceptions.PersistenceException:  ### Error updating database.  C ...

  3. SSM中mybtis报错### The error may involve defaultParameterMap ### The error occurred while setting param

    首先是前端弹出错误框如下: 查看后台报错信息如下 ### Cause: java.sql.SQLException: Error ; uncategorized SQLException; SQL s ...

  4. mybatis报错### The error may involve defaultParameterMap ### The error occurred while setting paramete

    前两天写的一个springboot+mybatis的小项目在一个修改数据库数据的功能出现了 ###The error may involve defaultParameterMap ###The er ...

  5. 查询时报错The error may involve defaultParameterMap ### The error occurred while setting parameters

    查询时报错The error may involve defaultParameterMap ### The error occurred while setting parameters 分页查询报 ...

  6. The error may involve defaultParameterMap ### The error occurred while setting paramete

    eclipse报错### The error may involve defaultParameterMap ### The error occurred while setting paramete ...

  7. Mybatis The error may involve defaultParameterMap ### The error occurred while setting parameters

    因为参数为空导致"<"foreach collection="ids" item="id" separator=",&quo ...

  8. mybatis错误:bad SQL grammar [];error occurred while setting parameters;involve defaultParameterMap处理

    业务描述:由于处理数据量庞大,多表进行拆分,每次任务新建一个表.在往新建表(表名要传参)插入数据时,提示错误: Error updating database.  Cause: java.sql.SQ ...

  9. mybatis使用foreach进行批量操作 The error may involve defaultParameterMap

    触发现象 xml: <insert id="insertByList"><foreach collection="tagList" item= ...

最新文章

  1. c语言程序设计试题及答案十,C语言程序设计试题试题及答案.doc
  2. 2020牛客多校G[并查集的两种思想,按秩合并+路径压缩]
  3. android考勤系统,Android端实现考勤管理系统
  4. 使用AutoIt实现UI自动化上传附件
  5. 【数据结构与算法】之深入解析“消除游戏”的求解思路与算法示例
  6. 专访刘伟:软件开发人员的内功修炼之道
  7. java常用的搜索引擎_我掏空了各大搜索引擎,给你整理了154道Java面试题!
  8. ASP.NET之Ajax系列(三)
  9. 项目-字典-更新字典分组
  10. mkfs.ext3 快速格式化_U盘数据快速恢复
  11. 漂浮广告代码html,漂浮广告的JS代码(经典)
  12. 为什么html中图片显示不出来,网页图片显示不出来该怎么办?
  13. 使用 Java 进行 HL7 编程
  14. 视频,图像,像素,分辨率,RGB, YUV简单说明
  15. 百度地图 JS API Marker自定义图标
  16. UVa 1645 - Count
  17. [Unity][游戏实现][UGUI][AnimatorAnimation]Graveyard Keeper守墓人UI实现
  18. EEA为以太坊以隐私为主的Web应用发布标准化架构栈
  19. 使用Veritas Volume Replicator(VVR)对Oracle数据库进行容灾
  20. java中config是什么意思,详解Spring中的JavaConfig注解

热门文章

  1. AI入门: 关于人工智能的深度思考
  2. v搜 visio 19版本 学生使用方法
  3. cip核字号验证_cip数据核字号的全称是什么
  4. 基于S7-200 PLC和MCGS组态的水箱水位控制系统设计 组态王动画仿真,带PLC源代码,plc程序每一条都带着解释
  5. 判断字符串是否相等StringUtils.equals和String.equals
  6. GB28181协议开发介绍
  7. 分布式定时任务调度中心
  8. Win10安装Rtree包报错:OSError: could not find or load spatialindex_c-64.dll
  9. android 自定义apk名,Android Studio 打包自定义apk文件名
  10. Matplotlib.pyplot 常用方法(一)