Hi,
I'm a jdbc/spring newbie and trying to perform some simple queries:
1) I have a CAR_TABLE with two columns CAR_MAKE and CAR_MODEL both strings. How do I get a list of Car objects..
I tried this:
but this gives me:HTML Code:public List<Car> getCars() { String sql = "select CAR_MAKE, CAR_MODEL from CAR_TABLE"; RowMapper mapper = new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Car car = new Car(); car.setMake(rs.getString("CAR_MAKE")); car.setModel(rs.getString("CAR_MODEL")); return car; } }; return (List<Car>)jdbcTemplate.queryForObject(sql, mapper); }
Exception in thread "main" org.springframework.dao.IncorrectResultSizeDataAcc essException: Incorrect result size: expected 1, actual 4515
also 2) How do I get just a list of strings for all elements in the CAR_MAKE column?
Thanks very much, Jason


Reply With Quote