今天想实现给指定表插入数据,出现了

### Error updating 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 ''api_assets0' (id,name, level,type,file_id)
values
(3' at line 1
### The error may exist in file [E:\java\project\admin\devide\target\classes\mapper\ApiAssetsMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into ? (id,name, level,type,file_id) values (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?)
### 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 ''api_assets0' (id,name, level,type,file_id)
values
(3' 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 ''api_assets0' (id,name, level,type,file_id)
values

mapper里

int insert(@Param("list") List<ApiAssets> list,@Param("one") String one);

XML里

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.abc.devide.demo.mapper.ApiAssetsMapper">
……
<insert id="insert">
insert into #{one} (id,name, level,type,file_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.name}, #{item.level},#{item.type},#{item.fileId})
</foreach>
</insert> </mapper>

解决方法:

  使用 ${} 接受表名,#{}接受其他参数

将insert部分改为

<insert id="insert">
insert into ${one} (id,name, level,type,file_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.name}, #{item.level},#{item.type},#{item.fileId})
</foreach>
</insert>

就可以成功执行了

${} 同 #{} 的区别 查看

解决mybatis中#{}导致的The error may involve defaultParameterMap的问题的更多相关文章

  1. 解决mybatis中转义字符的问题

    xml格式中不允许出现类似“>”这样的字符,有如下两种解决方法 方法一:使用转义字符 SELECT * FROM test WHERE 1 = 1 AND start_date <= CU ...

  2. 解决mybatis中 数据库column 和 类的属性名property 不一致的两种方式

    解决方式way1:resultMap (1)studentMapper.xml <!-- 当数据库的字段名 和 类的属性名 不一致的时候的解决方式:2种 way1--> <selec ...

  3. [已解决] MyBatis 中bind用法

    JAVA: TC_ENTR_FLOW selectFlowForUpdate(String ENTR_ID); XML: <select id="selectFlowForUpdate ...

  4. ### The error may involve defaultParameterMap ### The error occurred while setting parameters

    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Query was empty; bad SQL grammar [ ...

  5. “mybatis 中使用foreach 传

    为了帮助网友解决“mybatis 中使用foreach 传”相关的问题,中国学网通过互联网对“mybatis 中使用foreach 传”相关的解决方案进行了整理,用户详细问题包括:mybatismap ...

  6. 学习Spring Boot:(十二)Mybatis 中自定义枚举转换器

    前言 在 Spring Boot 中使用 Mybatis 中遇到了字段为枚举类型,数据库存储的是枚举的值,发现它不能自动装载. 解决 内置枚举转换器 MyBatis内置了两个枚举转换器分别是:org. ...

  7. 在mybatis中使用存储过程报错java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: PLS-00905: 对象 USER1.HELLO_TEST 无效 ORA-06550: 第 1 行, 第 7 列:

    hello_test是我的存储过程的名字,在mapper.xml文件中是这么写的 <select id="getPageByProcedure" statementType= ...

  8. 解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题

    下面两种现象,用同一种方法解决 1.解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题 2.突然有一天首页访问图片很慢,至少隔20多秒所有图片才会出来.(解析:app使 ...

  9. Android中解决图像解码导致的OOM问题

    Android中解决图像解码导致的OOM问题 原文链接:http://blog.csdn.net/zjl5211314/article/details/7042017

随机推荐

  1. form.submit()提交后返回数据的处理

    form.submit()发送请求一般是单向的,如果需要取返回的数据,一般会发送ajax请求,但是如果form中有附件呢?(以后有时间给大家分享ajax上传附件的功能),确实需要返回数据来知道该功能是 ...

  2. virtualbox通过Nat模式上网,宿主机与宿主机互通

    本地搭建virtualbox,开始用的nat转发模式,这样的话宿主机没法访问虚拟机里面的服务.比如nginx网站.这样很不方便 . 在网上找了好久,终于找到了方案.那就是再添加一块虚拟网卡. 在虚拟机 ...

  3. MySQL语言分类——DML

    DML DML的全称是Database management Language,数据库管理语言.主要包括以下操作: insert.delete.update.optimize. 本篇对其逐一介绍 IN ...

  4. 解决 Electron 5.0 版本出现 require is not defined 的问题

    Electron已经发布了5.0正式版,升级后发现原来能运行的代码报错提示require is not defined 经查相关资料,原来官方在5.0版本修改了nodeIntegration的默认值, ...

  5. c# 开发+MySql数据库

    今天就一个客户端的任务:1.把Excel文件转成特定格式插入到数据库中:2.查出该文件,并且导出Excel文件:3.如果插入数据错误,则把刚插入的数据删除掉.感觉比较简单,可是,墨迹了一天呀....总 ...

  6. kubernetes学习控制器之StatefulSet控制器

    StatefulSet介绍 一.StatefulSet概述 StatefulSet是用来管理stateful(有状态)应用的StatefulSet管理Pod时,确保Pod有一个按序增长的ID与Depl ...

  7. pip requirements.txt

    生成文件 pip freeze > requirements.txt 依赖库会导到于requirements.txt 比如:   image.png 从requirements.txt安装依赖库 ...

  8. PHP 格式化显示时间 date() 函数【转】

    date() 函数 功能:用于格式化时间,返回一个字符串.  语法:string date( string format [, int timestamp] ),其中参数 format 表示时间格式化 ...

  9. 集成学习-Majority Voting

    认识 集成学习(Ensemble Methods), 首先是一种思想, 而非某种模型, 是一种 "群体决策" 的思想, 即对某一特定问题, 用多个模型来进行训练. 像常见的单个模型 ...

  10. Mysql数据库之调整最大连接数

    .查看最大连接数 show variables like '%max_connections%'; 2.修改最大连接数 set GLOBAL max_connections = 200; 以下的文章主 ...