当前位置: 首页 > news >正文

org.springframework.jdbc.BadSqlGrammarException: Cause: java.sql.SQLException: Column count 异常

开发中运行mysql脚本,发现提示mysql提示Column count doesn't match value count at row 1异常,坚持后发现是由于写的SQL语句里列的数目和后面的值的数目不一致, 

比如insert into 表名 (field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个异常的。 


org.springframework.jdbc.BadSqlGrammarException:   

### Error updating database.  Cause: java.sql.SQLException: Column count doesn't match value count at row 1
### The error may involve com.jq.mall.product.biz.dao.ProductDAO.insertProduct-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: Column count doesn't match value count at row 1
; bad SQL grammar []; nested exception is java.sql.SQLException: Column count doesn't match value count at row 1
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346)
at $Proxy6.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:231)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:56)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
at $Proxy7.insertProduct(Unknown Source)
at com.jq.mall.product.biz.service.impl.ProductServiceImpl.updateOrSaveProduct(ProductServiceImpl.java:97)
at com.jq.mall.product.biz.service.impl.MyTestCase.test(MyTestCase.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1021)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:22)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:51)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:29)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:118)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
... 26 more




      本文转自yjflinchong 51CTO博客,原文链接:http://blog.51cto.com/yjflinchong/1165074,如需转载请自行联系原作者





相关文章:

  • 如何在esxi环境中重启LUN。
  • Android应用程序发送广播(sendBroadcast)的过程分析(2)
  • 如何快速学习一个开源项目源码?
  • 表格花式效果
  • VSCode Vue文件格式化
  • 访问量统计
  • centos6.8 yum安装mysql 5.6
  • sqldatasource控件处理image类型数据
  • 快速构建Windows 8风格应用9-竖直视图
  • c++ 检查工具
  • 网管3.0时代的全面来临——Mocha BSM 先锋引领
  • 让KVM虚拟机支持console功能
  • Oracle的where条件in/not in中包含NULL时的处理
  • R710有数据下如何重装2003
  • awk学习
  • 【css3】浏览器内核及其兼容性
  • 【Redis学习笔记】2018-06-28 redis命令源码学习1
  • Angular4 模板式表单用法以及验证
  • Computed property XXX was assigned to but it has no setter
  • docker python 配置
  • fetch 从初识到应用
  • java B2B2C 源码多租户电子商城系统-Kafka基本使用介绍
  • Java IO学习笔记一
  • Java,console输出实时的转向GUI textbox
  • javascript 哈希表
  • java正则表式的使用
  • Linux Process Manage
  • Objective-C 中关联引用的概念
  • php面试题 汇集2
  • Promise面试题,控制异步流程
  • PyCharm搭建GO开发环境(GO语言学习第1课)
  • Spark VS Hadoop:两大大数据分析系统深度解读
  • 初识 webpack
  • 搭建gitbook 和 访问权限认证
  • 工作手记之html2canvas使用概述
  • 山寨一个 Promise
  • 400多位云计算专家和开发者,加入了同一个组织 ...
  • ​Base64转换成图片,android studio build乱码,找不到okio.ByteString接腾讯人脸识别
  • ​用户画像从0到100的构建思路
  • (02)Cartographer源码无死角解析-(03) 新数据运行与地图保存、加载地图启动仅定位模式
  • (C)一些题4
  • (C语言)逆序输出字符串
  • (C语言)输入自定义个数的整数,打印出最大值和最小值
  • (Java)【深基9.例1】选举学生会
  • (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)讲解
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (附源码)ssm高校社团管理系统 毕业设计 234162
  • (附源码)计算机毕业设计SSM基于健身房管理系统
  • (含react-draggable库以及相关BUG如何解决)固定在左上方某盒子内(如按钮)添加可拖动功能,使用react hook语法实现
  • (十七)Flask之大型项目目录结构示例【二扣蓝图】
  • (原創) 系統分析和系統設計有什麼差別? (OO)
  • (转) SpringBoot:使用spring-boot-devtools进行热部署以及不生效的问题解决
  • .NET CLR Hosting 简介
  • .NET Core、DNX、DNU、DNVM、MVC6学习资料
  • .net on S60 ---- Net60 1.1发布 支持VS2008以及新的特性