在使用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的更多相关文章

  1. 使用JdbcTemplate报 Incorrect column count: expected 1, actual 5错误解决

    Incorrect column count: expected 1, actual 5 在使用jdbc的querForObject queryForList的时候,出现Incorrect colum ...

  2. Incorrect column count: expected 1, actual 5,JdbcTemplate queryForList 出错

    spring JdbcTemplate  queryForList 出错 Incorrect column count: expected 1, actual 5 >>>>&g ...

  3. Incorrect column count: expected 1, actual 2

    List<Long> idList = queryForList("ass.pageQuery_sgIds", paramMap, Long.class); 报错:In ...

  4. Incorrect column count: expected 1, actual 6

    JdbcTemplate使用时出现了一些问题: 解决办法:

  5. QueryError:Incorrect result size: expected 1, actual 0

    1.错误描述 QueryError:Incorrect result size: expected 1, actual 0 2.错误原因 3.解决办法

  6. ORA-00001:unique constraint violated 以及 Incorrect result size: expected 1, actual 0

    往数据库中插入数据时报错:   www.2cto.com   ORA-00001: unique constraint (IDX_CARTON_HEADER)violated.   即往CARTON_ ...

  7. (后端)org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0

    两种方案: 用queryForList方法替换queryForObject或者queryForMap,因为这两个方法必须要有值,不能为空. 把这个异常捕获,用try/catch. 这个查询的结果是nu ...

  8. 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, ...

  9. 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 ' ...

随机推荐

  1. 条目二十六《iterator优先于const_iterator、reverse_iterator以及const_reverse_iterator》

    条目二十六<iterator优先于const_iterator.reverse_iterator以及const_reverse_iterator> 这几个东西不是类型来的,而是不同的类,所 ...

  2. js 正则常用方法

    定义正则: 1 var re = new RegExp(“a”); //RegExp对象.参数就是我们想要制定的规则.有一种情况必须用这种方式,下面会提到. 2 var re = /a/; // 简写 ...

  3. python高级(五)—— python函数(一等对象)

    本文主要内容 一等对象 普通函数 & 高阶函数 可调用对象 & 自定义可调用类型 函数内省 函数注释 python高级——目录 文中代码均放在github上:https://githu ...

  4. python全栈开发_day10_函数的实参和形参

    一:函数的实参和形参 实参是在调用函数时()出现的外界的实际的值 形参不能再函数外部直接使用 1)实参的两种形式 实参是调用函数时()中传入的参数 1.位置实参 def a(a): print(a) ...

  5. java实现图片文字识别的两种方法

    一.使用tesseract-ocr 1.    https://github.com/tesseract-ocr/tesseract/wiki上下载安装包安装和简体中文训练文件 window64位安装 ...

  6. 【python】Scrapy爬虫框架入门

    说明: 本文主要学习Scrapy框架入门,介绍如何使用Scrapy框架爬取页面信息. 项目案例:爬取腾讯招聘页面 https://hr.tencent.com/position.php?&st ...

  7. lua-redis-parser module

    https://github.com/openresty/lua-redis-parser 此模块主要是处理redis请求和响应的. local parser = require "redi ...

  8. SQL语句模糊查询年月

    <if test="uploadTime != null" > <![CDATA[ and date_format(w.upload_time, '%Y%m') ...

  9. nginx, flask, wsgi

    原来自己还没搞懂这些. 首先post一个观点: nginx应该是没解析任何东西,就判断是不是http请求,然后转发?或者判断是不是tcp请求,然后转发. 所以给了python后台就可以用wsgi解包. ...

  10. (转)Python 标准库笔记:string模块

    String模块包含大量实用常量和类,以及一些过时的遗留功能,并还可用作字符串操作. 原文:http://www.10tiao.com/html/384/201709/2651305041/1.htm ...