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);
}
这样才可以
在此记下。
Incorrect column count: expected 1, actual 5的更多相关文章
- 使用JdbcTemplate报 Incorrect column count: expected 1, actual 5错误解决
Incorrect column count: expected 1, actual 5 在使用jdbc的querForObject queryForList的时候,出现Incorrect colum ...
- 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 2
List<Long> idList = queryForList("ass.pageQuery_sgIds", paramMap, Long.class); 报错:In ...
- Incorrect column count: expected 1, actual 6
JdbcTemplate使用时出现了一些问题: 解决办法:
- QueryError:Incorrect result size: expected 1, actual 0
1.错误描述 QueryError:Incorrect result size: expected 1, actual 0 2.错误原因 3.解决办法
- ORA-00001:unique constraint violated 以及 Incorrect result size: expected 1, actual 0
往数据库中插入数据时报错: www.2cto.com ORA-00001: unique constraint (IDX_CARTON_HEADER)violated. 即往CARTON_ ...
- (后端)org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0
两种方案: 用queryForList方法替换queryForObject或者queryForMap,因为这两个方法必须要有值,不能为空. 把这个异常捕获,用try/catch. 这个查询的结果是nu ...
- Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50096, now running 50173.
IDEA链接mysql提示 Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50096, ...
- ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50560, now running 50725. Please use mysql_upgrade to fix this error.
centos7.5 登入mysql,进行授权报错 问题: mysql> grant all privileges on *.* to 'lvhanzhi'@'%' identified by ' ...
随机推荐
- 使用 final 关键字修饰一个变量时,是引用不能变,还是引用的对象不能变?
使用 final 关键字修饰一个变量时,是指引用变量不能变,引用变量所指向的对象中的内容还是可以改变的.例如,对于如下语句:final StringBuffer a=new StringBuffer( ...
- restful api上传文件(基础)-springboot
基于restful api格式的文件上传(只是上传到本地): package com.nxz.controller; import com.nxz.entity.FileInfo; import or ...
- POJ_3468 A Simple Problem with Integers 【线段树区间查询+修改】
一.题目 POJ3468 二.分析 裸的线段树区间查询+修改. 三.AC代码 #include <cstdio> #include <iostream> #include &l ...
- simulate UE activity
can: 1,connect, disconnect 2,configure serial,nic,com,model,version,IMEI,IMSI,IP 3,various AT comman ...
- 【中间件】Struts2系列漏洞POC小结
#Struts2-045 ''' CVE-2017-5638 影响范围:Struts 2.3.5 – Struts 2.3.31,Struts 2.5 – Struts 2.5.10 触发条件:基于J ...
- 在MonoGame中SetRenderTarget会把后备缓冲区清除的解决方法
在MonoGame中SetRenderTarget会把后备缓冲区清除的解决方法: 在构造函数中添加事件:graphics.PreparingDeviceSettings += Graphics_Pre ...
- 分分钟钟学会Python - 数据类型(list、tuple)
第四节 数据类型(列表.元祖) 今日内容 列表 元祖 1.列表 1.格式 users = ["ji",1,3,"gyhj"] 2.公共方法 1.len #计算长 ...
- 4.nginx动静分离
动静分离,就是将css.js.jpg等静态资源和jsp等动态资源分开处理,以此提高服务器响应速度,提高性能. 核心就是区分动态和静态资源 图片转自:https://www.cnblogs.com/xi ...
- 文献综述十六:基于UML的中小型超市管理系统分析与设计
一.基本信息 标题:基于UML的中小型超市管理系统分析与设计 时间:2016 出版源:Journal of Xiangnan University 文件分类:uml技术系统的研究 二.研究背景 开发一 ...
- myEclipse卡顿解决
1 .关闭MyEclipse的自动validation windows > perferences > myeclipse > validation 将Build下全部勾取消 如果你 ...