jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 6
错误方法
- jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 6
@Override
public Student selectStudentById(Integer id) {
String sql = "select * from tab_student where id = ?";
return jdbcTemplate.queryForObject(sql, Student.class, id);
}
正确方式
@Override
public Student selectStudentById(Integer id) {
String sql = "select * from tab_student where id = ?";
return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Student.class), id);
}