mysql Column count doesn't match value count at row 1
今天执行批量插入的操作,发现报了错 mysql Column count doesn't match value count at row 1。
后来发现原因:是由于写的SQL语句里列的数目和后面的值的数目不一致, 比如insert into 表名 (field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个错误的。
查看mapper写法
<insert id="insertBatch" useGeneratedKeys="true" parameterType="java.util.List">
INSERT INTO sys_basic_info(
<include refid="dbColumns" />
) VALUES
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.groupId},
#{item.groupName},
#{item.groupCode}
</foreach>
</insert>
原因很容易发现,foreach标签属性open和close配置有误!这样大括号会把整体包起来,正确应为:
<insert id="insertBatch" useGeneratedKeys="true" parameterType="java.util.List">
INSERT INTO sys_basic_info(
<include refid="dbColumns" />
) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.groupId},
#{item.groupName},
#{item.groupCode}
)
</foreach>
</insert>
mysql Column count doesn't match value count at row 1的更多相关文章
- mysql提示Column count doesn't match value count at row 1错误
mysql提示Column count doesn't match value count at row 1错误,后来发现是由于写的SQL语句里列的数目和后面的值的数目不一致, 比如insert in ...
- mysql错误:Column count doesn't match value count at row 1
mysql错误:Column count doesn't match value count at row 1 mysql错误:Column count doesn't match value cou ...
- 开发中运行mysql脚本,发现提示mysql提示Column count doesn't match value count at row 1错误
开发中运行mysql脚本,发现提示mysql提示Column count doesn't match value count at row 1错误, 调试后发现是由于写的SQL语句里列的数目和后面的值 ...
- sql语句出错:Column count doesn't match value count at row 1
报错内容: java.sql.SQLException: Column count doesn't match value count at row 1 at com.mysql.jdbc.SQLEr ...
- 报错:Column count doesn't match value count at row 1
mysql错误:Column count doesn't match value count at row 1 意思是存储的数据与数据库表的字段类型定义不相匹配. 解决办法:检查段类型是否正确, 是否 ...
- [Mybatis - 1A] - Cause: java.sql.SQLException: Column count doesn't match value count at row 1
严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw ex ...
- [Err] 1136 - Column count doesn't match value count at row 1
1 错误描述 [Err] 1136 - Column count doesn't match value count at row 1 Procedure execution failed 1136 ...
- java.sql.SQLException:Column count doesn't match value count at row 1
1.错误描述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因 在插入数据时,插入的字段 ...
- java.sql.SQLException: Column count doesn't match value count at row 1 Query: insert into category values(null,?,?,?) Parameters: [1111111, 1111, 软件]
java.sql.SQLException 问题: java.sql.SQLException: Column count doesn't match value count at row 1 Que ...
随机推荐
- [LeetCode] 162. Find Peak Element_Medium tag: Binary Search
A peak element is an element that is greater than its neighbors. Given an input array nums, where nu ...
- Mac Maven配置
Maven下载链接,解压到指定目录,我这里是 /Users/JYH/Desktop/Hadoop-2.7.2/apache-maven-3.3.9 打开终端,配置环境变量 输入命令 vi ~/.bas ...
- zip()
zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表. 如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以 ...
- Linq测试/查看工具——LinqPad
LinqPad 官方:http://www.linqpad.net/ 介绍: 即时测试任何C#/ F#/ VB片段或程序LINQ支持--SQL / CE / Azure,Oracle,SQLite和M ...
- 判断数组对象里面的某个属性全部为true才执行下一步操作
比如数据[ {name:'张三',isshow:'false'},name:'李四',isshow:'false'}, ] 这里是自己写的验证,没用elemten的 如果有2张票,需要刷2张身份证,则 ...
- 懒汉处理dapper字段名与属性名的映射方式
你还以为走路是世上最简单的事情呢?只不过是把一只脚放到另一只脚前面.但我一直很惊讶这些原本是本能的事情实际上做起来有多困难.而吃,吃也是一样的,有些人吃起东西来可困难了.说话也是,还有爱.这些东西都可 ...
- html5-article元素
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- Big Event in HDU (母函数, 玄学AC)
Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't k ...
- Abandoned country(最小生成树+树形DP)
#include<bits/stdc++.h> using namespace std; struct node{ int u, v, w, nex; bool gone; node(){ ...
- 设计模式之Singleton(单态)(转)
定义: Singleton模式主要作用是保证在Java应用程序中,一个类Class只有一个实例存在. 在很多操作中,比如建立目录 数据库连接都需要这样的单线程操作. 还有, singleton能够被状 ...