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

### 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. 基于串口的SD_card系统

    概述 基于串口的SD_card系统1, 扫描文件:2, 新建文件:3, 删除文件:4, 写入文件:5, 读取文件. 整个文件系统的串口通信方式都是ASC通信方式. 文件系统分为简单实用方式和专业使用方 ...

  2. 新一代ActiveMQ —— Apache ActiveMQ Artemis

    资料: .net demo : https://github.com/apache/activemq-artemis/tree/master/examples/protocols/amqp/dotne ...

  3. C# 文件监听类 FileSystemWatcher 属性

    属性: Path——这个属性告诉FileSystemWatcher它需要监控哪条路径.例如,如果我们将这个属性设为“C:Temp”,对象就监控那个目录发生的所有改变.IncludeSubDirecto ...

  4. Asp.NetCoreWebApi - RESTful Api

    目录 参考文章 REST 常用http动词 WebApi 在 Asp.NetCore 中的实现 创建WebApi项目. 集成Entity Framework Core操作Mysql 安装相关的包(为X ...

  5. 1 Python命令行参数(脚本神器)

    #!/usr/bin/env python3.7 # -*- coding:utf-8 -*- # Author: Lancer 2019-09-02 10:07:21 import sys,geto ...

  6. VirtualBox安装Ubuntu-18.04-Server笔记

    准备 安装'Windows Terminal' 安装WSL 安装VirtualBox 安装 虚拟磁盘映像文件选择创建在SSD(如果有) 选择openssh,公钥从GitHub获取,前提是GitHub已 ...

  7. js数组去重 数组拼接 替换数组中的指定值 递归数组 判断数组中是否存在指定值 数组求和 根据条件判数组值

    这是学习过程中记录的一些关于数组操作的常用属性或方法,记录一下方便以后使用. // 数组去重 var arr1 = [1,1,2,3,4,5,6,3,2,4,5,'a','b','c','a',6,7 ...

  8. Java 之 Properties 集合

    一.Properties 概述 Properties 是Hashtable的子类,不允许key和value是null,并且它的key和value的类型都是String. 二.常用方法 1.构造方法 P ...

  9. c# 读取数据库得到dateset

    public DataSet GetCraftInformation(string connectionString, string opName, string productType)       ...

  10. <Android Studio> 3.打包APK

    我的IDE版本是 3.5 我希望输出的apk文件格式是: 名称_v版本_release/debug_日期 时间.apk 步骤: 1.打开build.gradle 末尾添加如下代码 def releas ...