qureyForObject

· Spring
결과가 1행인 경우 사용할 수 있는 qureyForObject 메서드에 대해 알아봅시다. 결과가 1행인 경우 사용할 수 있는 qureyForObject() 메서드 다음은 query() 메서드를 사용한 코드입니다. public int count(){ List results = jdbcTemplate.query( "select count(*) from MEMBER", new RowMapper(){ @Override public Integer mapRow(Resultset rs, int rowNum) throws SQLException{ return rs.getInt(1); } }); return results.get(0); } count(*) 쿼리는 결과가 한 행뿐이니 쿼리 결과를 List로 받기보다는 In..
runnnerDevHong
'qureyForObject' 태그의 글 목록