Certification/Spring(2V0-72.22, SCP)

What is the difference between checked and unchecked exceptions?

엘호리스 2021. 11. 7. 01:20

What is the difference between checked and unchecked exceptions?


Checked exception Unchecked exception
예외 발생 컴파일시 예외 catch부에서 처리 런타임 도중 발생하는 catch되지 않은 예외
예외 처리 예외처리 필수 예외처리 필수 아님
트랜잭션 처리 롤백하지 않음 롤백함
예시 IOException, SQLException, ClassNotFoundException, InvocationTargetException NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, NumberFormatException

Why does Spring prefer unchecked exceptions?

What is the Spring data access exception hierarchy?

  • Data Access Exception is a Runtime Exception
  • Examples of concrete Data Access Exceptions
    • CannotAcquireLockException
    • CannotCreateRecordException
    • DataIntegrityViolationException
  • Purpose of this hierarchy is to create abstraction layer on top of Data Access APIs to avoid coupling with concrete implementation of Data Access APIs

Spring Professional Exam Tutorial v5.0 - Dominik Cebula