2011년 11월 3일 목요일

[JAVA] ResultSet의 결과수에 따라 로직을 만들려고 할때...

자바에서 ResultSet으로 결과를 Fetch 한 뒤 총 몇개의 열이 Fetch 되었나는 다소 복잡하다.

conn = DBHandler.getConnection()

pstmt = conn.prepareStatement(Query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = pstmt.executeQuery();

rs.last();
int vFetchedRow = rs.getRow();
rs.beforeFirst();

이후 다시
while(rs.next){
/// codes
}

해도 에러가 나지 않는다.

댓글 없음: