使用JdbcTemplate报 Incorrect column count: expected 1, actual 5错误解决
在使用jdbc的querForObject queryForList的时候,出现Incorrect column count: expected 1, actual 5
比如
String sql = "select * from sysuser where id = 3";
SysUser s = this.jdbcTemplate.queryForObject(sql, SysUser.class);
其实这样是不对的,
应该为
String sql = "select name from sysuser where id = 3";
String s = this.jdbcTemplate.queryForObject(sql, String.class);
System.out.println(s);
这个 jdbcTemplate.queryForObject(sql, requiredType) 中的requiredType应该为基础类型,和String类型。
如果想查真正的object应该为
List<SysUser> userList = jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<SysUser>(SysUser.class));
if(null!=userList&&userList.size()>0){
SysUser user = userList.get(0);
}
这样才可以
在此记下。
使用JdbcTemplate报 Incorrect column count: expected 1, actual 5错误解决的更多相关文章
- Incorrect column count: expected 1, actual 5,JdbcTemplate queryForList 出错
spring JdbcTemplate queryForList 出错 Incorrect column count: expected 1, actual 5 >>>>&g ...
- Incorrect column count: expected 1, actual 5
在使用jdbc的querForObject queryForList的时候,出现Incorrect column count: expected 1, actual 5 比如 String sql = ...
- Incorrect column count: expected 1, actual 2
List<Long> idList = queryForList("ass.pageQuery_sgIds", paramMap, Long.class); 报错:In ...
- Incorrect column count: expected 1, actual 6
JdbcTemplate使用时出现了一些问题: 解决办法:
- ORA-00001:unique constraint violated 以及 Incorrect result size: expected 1, actual 0
往数据库中插入数据时报错: www.2cto.com ORA-00001: unique constraint (IDX_CARTON_HEADER)violated. 即往CARTON_ ...
- QueryError:Incorrect result size: expected 1, actual 0
1.错误描述 QueryError:Incorrect result size: expected 1, actual 0 2.错误原因 3.解决办法
- python问题:IndentationError:expected an indented block错误解决《转》
python问题:IndentationError:expected an indented block错误解决 标签: python语言 2012-07-07 17:59 125145人阅读 评论( ...
- (后端)org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0
两种方案: 用queryForList方法替换queryForObject或者queryForMap,因为这两个方法必须要有值,不能为空. 把这个异常捕获,用try/catch. 这个查询的结果是nu ...
- [转]python问题:IndentationError:expected an indented block错误解决
分类: python学习笔记2012-07-07 17:59 28433人阅读 评论(4) 收藏 举报 python语言 原文地址:http://hi.baidu.com/delinx/item/17 ...
随机推荐
- 日历插件My97DatePicker的使用
在开发过程中,我们会经常遇到让用户输入日期的表单,这类表单处理起来也不是太繁琐,就是简单的字符串和日期之间的转换.但是,如果用户不按照已设定的日期格式进行输入,必定会造成不必要的麻烦.为了更好的处理这 ...
- PLSQL
select t.*,rowid from Table t; 编辑器设置
- [转] 理解 Thread.Sleep 函数
原文链接:http://www.cnblogs.com/ILove/archive/2008/04/07/1140419.html 我们可能经常会用到 Thread.Sleep 函数来使线程挂起一段时 ...
- [转] This Android SDK requires Android Developer Toolkit version 23.0.0 or above
问题描述: This Android SDK requires Android Developer Toolkit version 23.0.0 or above. Current version ...
- telnet测试制定地址端口号
cmd下,命令 telnel+空格+ip或者网站+空格+端口号 端口可以用: 需要开通windows服务:
- bootstrap弹出提示窗口功能
大家常用弹出提示成功或失败时候喜欢用alert,如果不用这个,写个弹窗又麻烦,bootstrap中就有个方法 alert("操作成功"); commonAlert("操作 ...
- java调用cmd命令删除文件夹及其所有内容
/** * *删除D盘下面test目录,感觉以前用io流遍历删除好慢! * **/ public static void main(String[] args) { Runtime run = Run ...
- Servlet题库
一. 填空题 Servlet中使用Session对象的步骤为:调用 HttpServletRequest.getSession() 得到Session对象,查看Session对象,在会话中保 ...
- osgconv 将多个模型合成一个模型
osgconv a.osg b.osg c.osg BigOne.ive 以上命令的作用是将a.osg.b.osg.c.osg三个模型合并到BigOne.ive模型
- HTML 表格垂直对齐方式
HTML表格标记教程(25):行的垂直对齐属性VALIGN在垂直方向上,可以设定行的对齐方式,分别有居上.居中.居下3种.基本语法<TR VALIGN="TOP">&l ...