쿼리의 결과값이 없어 Empty Resultset 발생하는 경우(Illegal operation, EmptyResultException)
* 해당 글은 계속 수정 예정입니다.
최초 작성일 2023.04
마지막 수정일 2023.04
# 쿼리의 결과값이 없으면 Empty Resultset 발생
Empty ResultSet 으로 인한 Illegal operation 에러 상황을 가정해보겠습니다.
가령, 1번쿼리를 수행 후 결과값을 이용해 2번쿼리를 돌리도록 작성하였다면,
(ex) 1번쿼리 수행결과 -> while문 -> 2번쿼리 수행)
1번쿼리의 결과가 없거나, 혹은 1번쿼리의 결과는 있더라도 2번쿼리의 결과가 없을 경우. Empty Resultset이 발생합니다.
# setEmptyResultCheck 설정
setEmptyResultCheck 설정 후 쿼리 조회결과가 없는 결과의 에러처리는 아래와 같다.
1. setEmptyResultCheck( true )
=> no_recode : 조회결과 없음
=> catch에서 잡힘 (EmptyResultException 로그찍힘)
=> catch가 없는 경우?
=> 그냥 아래 로직으로 넘어감. 따라서 에러 핸들링을 따로 해야함. ( 에러 핸들링 => Return OR throw Exception )
=> 에러 핸들링(Return OR throw Exception) 상세내용은 아래 참고 (본인 블로그)
https://drsggg.tistory.com/750
return or throw Exception
공부한것들을 정리하는 블로그 입니다. return or throw Exception 본문
drsggg.tistory.com
2. setEmptyResultCheck( false )
=> no_recode : 조회결과 없음
=> catch 안잡힘(에러x)
=> docall 자체가 null