본문 바로가기
카테고리 없음

[JAVA] 자바 예외를 SQLException로 형변환 DB에러코드로 핸들링

by #무한동력 2020. 7. 21.
	try {
			list = wmsDao.queryForList("", paramMap);
		}catch(RuntimeException e) {
			Throwable cause = e.getCause();
			if(cause.getCause().getCause() instanceof SQLException) {
				int sqlErrCode = ((SQLException)cause.getCause().getCause()).getErrorCode();
				 if(sqlErrCode == 1489) {//ORA_01795
		    		throw new TestException("에러메세지~");
				 }
				 throw new TestException(e);
			}
			throw new TestException(e);
		}

 

댓글