Results 1 to 2 of 2

Thread: Why I get IncorrectResultSetColumnCountException?

  1. #1
    Join Date
    Jan 2006
    Location
    El Dorado
    Posts
    80

    Default Why I get IncorrectResultSetColumnCountException?

    Hi.
    I have this class:
    Code:
    class F1 {
      Long id;
      String name;
      
      //empty const and setter and getters
    }
    Inside the DAO:
    Code:
    String sql = "select id, name from f1;
    return namedParameterJdbcTemplate.queryForList(sql, new HashMap(), F1.class);
    But I got this exception:
    org.springframework.jdbc.IncorrectResultSetColumnC ountException
    I tried:
    return namedParameterJdbcTemplate.queryForList(sql, new HashMap());
    It works.
    Why?
    Thank you all.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    I suggest you read the javadocs of the class and read the reference guide on how to use Spring JDBC.

    You can only use it for resultsets with 1 column, not multiple. It only works for simple arguments i.e. String, Integer etc. not for custom classes. If you want to map custom classes you need to implement a RowMapper and use that instead.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •