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);
}
posted @ 2021-12-30 20:38  MikiKawai  阅读(623)  评论(0编辑  收藏  举报