IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 38

前端 未结 4 1874
刺人心
刺人心 2021-02-12 22:18

I am using JdbcTemplate to retrieve a Bean from the db. Here is my method:

public List  getTrackerData() {
    return List         


        
4条回答
  •  别跟我提以往
    2021-02-12 23:15

    This is happening because, the queryForList method you have used will not support for multiple columns. See the implementation of queryForList from JdbcTemplate

    public  List More ...queryForList(String sql, Object[] args, Class elementType) throws DataAccessException 
    {
        return query(sql, args, getSingleColumnRowMapper(elementType));
    }
    

    The getsingleColumnRowMapper() method creates a new RowMapper for reading result objects from a single column. You can use the method given below instead.

    public  List query(String sql, Object[] args, RowMapper rowMapper) throws DataAccessException        
     {
        return query(sql, args, new RowMapperResultSetExtractor(rowMapper));
    }
    

提交回复
热议问题