在使用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. Django 允许其他可以访问的设置

    第一步:在run下修改edit 第二步:host改为0.0.0.0 第三步:setting文件中将    ALLOWED_HOSTS 改为 :ALLOWED_HOSTS = ['*',] 这样就可以通 ...

  2. 使用 echart的jar包,传递到前台报 null错误

    表现:后台创建 Option的JsonObjject传递到前台之后,失败,F12控制台报错:无法定义null的属性xxx 原因:使用jar包里面的对象分装没有默认值,而我们自己使用时只是对需要的对象进 ...

  3. thinkphp3.2----实现伪静态和路由配置

    URL模式: 0.普通   http://localhost/qixin/ThinkCMF(test)_backup/index.php?g=user&m=login&a=index ...

  4. 分享自建的 Jrebel License Server 激活 Jrebel

    使用在线验证服务器激活 Jrebel 与 Idea 说明 代码来自于开源项目: gsls200808 / JrebelLicenseServerforJava 自建的服务地址 http://jrebe ...

  5. MySQL压缩版Windows环境进行安装配置

    MySQL下载地址:https://dev.mysql.com/downloads/mysql/ 选择对应的系统和相应的版本后点击Download进入下载页面,不需要登录,点击下面的“No thank ...

  6. ionic基础知识

    ion-header-bar(头部 页眉) 在内容顶部添加一个固定header栏. 用法 <ion-header-bar align-title="left" class=& ...

  7. Angular--TypeScript finalize 方法

    self._entityService .getAll() .pipe( finalize(() => { if (self.sheet && self.sheet.length ...

  8. PIE_SDK.NET功能表

  9. 整理的最全 python常见面试题

      整理的最全 python常见面试题(基本必考)① ②③④⑤⑥⑦⑧⑨⑩ 1.大数据的文件读取: ① 利用生成器generator: ②迭代器进行迭代遍历:for line in file; 2.迭代 ...

  10. Redis中算法之——Raft算法

    Sentinel系统选举领头的方法是对Raft算法的领头选举方法的实现. 在分布式系统中一致性是很重要的.1990年Leslie Lamport提出基于消息传递的一致性算法Paxos算法,解决分布式系 ...