`

spring-ResultSetColumnCountException: Incorrect column count

 
阅读更多

spring:3.0.4

 

调用jdbc.queryForObject(sql, PasswordProtect.class, userId,question);

 

public class PasswordProtect {
	private int id;
	private int userId;
	private int questionId;
	private String answer;
	private Date createTime;
	private int state;
.......

}
 

 

错误

org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 6
    at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:87)
    at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
    at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:1)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:648)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:728)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:744)
    at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject(SimpleJdbcTemplate.java:143)
    at match.modules.password.service.PasswordProtectServiceImpl.selectPasswordProtect(PasswordProtectServiceImpl.java:29)
    at match.modules.password.service.PasswordProtectServiceImpl.updatePasswordProtect(PasswordProtectServiceImpl.java:35)
    at match.wapactions.account.PasswordAction.passwordProtectQuestionUpdate(PasswordAction.java:191)
    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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    at match.commons.interceptor.UserLoginInterceptor.intercept(UserLoginInterceptor.java:138)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at match.commons.interceptor.SingleFileUploadInterceptor.intercept(SingleFileUploadInterceptor.java:88)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at match.commons.interceptor.NoCacheInteceptor.intercept(NoCacheInteceptor.java:37)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
    at match.commons.session.MemcachedSessionFilter.doFilterInternal(MemcachedSessionFilter.java:71)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
    at match.commons.ContentLengthFilter.doFilter(ContentLengthFilter.java:26)
    at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:602)
    at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
    at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
    at java.lang.Thread.run(Thread.java:662)

 

解决:

意思是:查出的数据有六列,它把jdbc.queryForObject(sql, PasswordProtect.class,userId,question);中的第一列转换成PasswordProtect.class,所以expected 1, actual 6,预期1列,但查出来的数据有6列

RowMapper<PasswordProtect> rm = ParameterizedBeanPropertyRowMapper.newInstance(PasswordProtect.class);
jdbc.queryForObject(sql, rm, userId,question);
 

 

 

 

 

分享到:
评论

相关推荐

    oracle报错大全(珍藏版)

    #### ORA-00065: FIXED_DATE Parameter Value Incorrect 当FIXED_DATE参数值不正确时触发。这可能是由于参数设置超出允许范围或格式错误。 #### ORA-00066: LOG_FILES Parameter Value Not Positive 当LOG_FILES...

    解决 libpng warning: iCCP: known incorrect sRGB profile

    在IT领域,尤其是在图像处理和开发中,"libpng warning: iCCP: known incorrect sRGB profile" 是一个常见的问题,特别是在使用Qt库进行图像操作时。这个问题涉及到颜色配置文件(iCCP)和标准红绿蓝(sRGB)色彩...

    解决方案libpng warning: iCCP: known incorrect sRGB profile.txt

    参考"解决问题:libpng warning: iCCP: known incorrect sRGB profile"[https://blog.csdn.net/WangJiankun_ls/article/details/79470739]文章,通过自己实践操作,得出结论,希望能帮助到你们

    FairyGUI-Unity-Plugin-3.4.0.zip

    - FIXED: Incorrect letter spacing on mobile platform. - FIXED: Same transition hook may be called twice. - FIXED: Exception raised when texture was disposed before object was disposed. 3.3.0 - NEW: ...

    MySQL 8.0.13设置日期为0000-00-00 00:00:00时出现的问题解决

    刚开始学习数据库操作,今天存数据时发现,保存的时候报错(Error 1292: Incorrect datetime value: '0000-00-00' for column 'deleted_at' at row 1) ,之后就搜索了下原因,是因为MySQL存日期时不允许出现这种格式...

    SQL Prompt_9.0.4.3408破解版

    SP-6704 : Fix incorrect vertical alignment with 'SELECT DISTINCT' and column list. SP-6724 : BP017 and BP018 shouldn't consider inner join as an issue. SP-6736 : MI003 'Unqualified column name' ...

    rk3588编译问题缺少lz4最新版本

    Incorrect parameters Usage : lz4 [arg] [input] [output] input : a filename with no FILE, or when FILE is - or stdin, read standard input Arguments : -1 : Fast compression (default) -9 :...

    PB12.5 dw 报错Line 130 Column 487 incorrect syntax问题解决

    在PowerBuilder 12.5(简称PB12.5)开发过程中,遇到“Line 130 Column 487 incorrect syntax”错误是一种常见的编程问题。这种错误通常出现在数据窗口(DataWindow,简称DW)对象的编译阶段,提示在指定的行号和列...

    tc错误代码完整集录

    54. **Incorrect use of default** - 解析:`default`关键字使用不当,通常出现在`switch`语句之外。 55. **Invalid indirection** - 解析:对非指针类型的间接引用,如对整型变量使用星号(*)。 56. **Invalid...

    ADSL拨号上网错误大全

    33. **632 - The structure size is incorrect** - 解释:结构大小不正确。 - 解决方法:检查拨号连接设置,确保所有配置信息均正确。 34. **633 - The port is already in use or is not configured for Remote ...

    Qt:解决使用png图片时,报错libpng warning: iCCP: known incorrect sRGB profile的问题

    然而,在处理某些PNG图像时,可能会遇到一个常见的错误提示:“libpng warning: iCCP: known incorrect sRGB profile”。这个错误是由于PNG图像的色彩配置文件(iCCP)与标准sRGB色彩空间不匹配导致的。在本文中,...

    MySQL数据库-错误1166 Incorrect column name

    在MySQL数据库中,错误1166 "Incorrect column name" 是一个常见的问题,它通常发生在尝试执行SQL语句,例如创建、更改或查询表结构时。这个错误提示表示数据库无法识别指定的列名,原因可能是因为列名存在无效字符...

    英语词汇学笔记(注释)整理.doc

    例如 `incomplete` 表示“不完整的”,`incorrect` 意为“不正确的”。 2. **Pejorative prefixes (贬义前缀)** - `mal-`: 表示“不好的”或“坏的”,如 `maltreat` 意为“虐待”,`malfunction` 意为“故障”。...

    英语常用前缀表.doc

    12. in-、im-、il-:无、向内、加强(例如:incorrect 不正确,impulse 冲动) 13. inter-:在……间(例如:international 国际的) 14. kilo-:千(例如:kilometer 千米) 15. micro-:微(例如:microbe 微生物...

    2011年自考英语(二)最全复习资料

    - **incorrect** (a): 不正确的 #### 11. Unintended (a非计划中的) - **intend** (v): 打算,计划 - **intention** (n): 打算 - **intended** (a): 计划中的 ### 二、课文难句讲解、分析 #### 例句 &gt; A ...

    SQL Prompt_9.0.6.3580破解版

    SP-6737 : Apply column alias style breaks script if using both old and new styles. SP-6774 : Fix incorrect message when user invoke 'find invalid objects' with code suggestions disabled.

    c++出错对照表 英汉对照

    - **Incorrect use of pointers** - 指针使用不当 - 解释:如果指针指向的内存被释放后仍然使用该指针,则可能导致未定义行为。确保了解指针生命周期并在适当时候释放内存。 - **Division by zero** - 除以零 -...

    解决报错libpng waring:iccp:known incorrect srgb profile

    在IT行业中,我们经常遇到各种报错,其中“libpng warning: iccp: known incorrect sRGB profile”是一个常见的错误,特别是在处理PNG图像时。这个警告通常发生在使用图像处理库,如libpng,来读取或操作包含色彩...

    jmeter-maven-plugin:JMeter Maven插件

    JMeter Maven插件 一个Maven插件,可以在您的构建中运行JMeter测试有关更改信息,请参见 。 上提供了配置插件所需的所有文档。 最新版本是3.3.0 ,它需要Maven&gt; = 3.5.2,并且默认为Apache JMeter 5.4.1 。...

Global site tag (gtag.js) - Google Analytics