에러처리
예외처리의 순서
1. try블록 안에서 예외가 발생하면 그 시점에서 코드의 실행을 중단한다
2. 발생된 예외의 종류가 catch 블럭의 () 안에서 지정한 예외와 일치하면 그 안의 코드 실행
3. catch 블록 안의 코드가 모두 실행되면 그 try-catch 이후의 코드 실행
finally
- finally : 반드시 실시하고 싶은 중요한 프로세스는 반드시 finally 블록 안에 작성해주자
- 보통 그러한 중요한 작업의 예로 파일쓰기 작업, 네트워크 연결 종료 처리등이 있음
- 생략이 가능하며, 실제로도 많은 경우 생략한다
try{
예외가 생길지도 몰라 조사를 할 코드들
}
catch(ArrayIndexOutOfBoundException e){
// ArrayIndexOutOfBoundException e 와 같이 소괄호 안에 예외이름과 그 예외를 지칭할 변수명 입력
//중괄호 안에는 예외 발생시 실행시킬 코드
}
finally{
예외 발생의 유무와 상관없이 반드시 실시하고 싶은 (중요한) 프로세스 코드
}
System.out.println(e) VS e.printStackTrace()
누구는 전자를 누구는 후자를 써서 차이점이 무엇인지 찾아보았다.
System.out.println(e)는 exception의 종류까지만 출력하고, e.printStackTrace()는 발생위치 등 좀더 디테일을 포함해 출력
System.out.println(e) is equivalent to System.out.println(e.toString())
System.out.println(e); :- only showing the exception. e.g.java.lang.ArithmeticException: / by zero e.printStackTrace(); :- showing the details of exception and where to cause exception in program with line number e.g. java.lang.ArithmeticException: / by zero at test.Test.main(Test.java:7)
With println: you only know what exception has been thrown
java.lang.UnsupportedOperationException: Not yet implemented
With printStackTrace: you also know what caused it (line numbers + call stack)
java.lang.UnsupportedOperationException: Not yet implemented
at javaapplication27.Test1.test(Test1.java:27)
at javaapplication27.Test1.main(Test1.java:19)
JPA
지금의 목표
- 내부 동작 방식 이해
- 어떤 SQL문을 만들어내는지 알기
- JPA가 언제 SQL을 실행하는지 이해하기
Git Rebase / git pull upstream master
# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:
git rebase upstream/master
git pull upstream master
'TIL WIL' 카테고리의 다른 글
TIL (0) | 2022.07.25 |
---|---|
20220722 TIL (0) | 2022.07.22 |
20220720 TIL (0) | 2022.07.20 |
20220719 TIL (0) | 2022.07.18 |
20220718 TIL (1) | 2022.07.18 |