-
Notifications
You must be signed in to change notification settings - Fork 169
[Spring JDBC] 진웨이얀5,6,7단계 미션제출합니다. #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: zinyan
Are you sure you want to change the base?
Conversation
juanxiu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~!
| keyHolder | ||
| ); | ||
| // Generated id | ||
| Long id = keyHolder.getKey().longValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyHolder 에서 생성된 키를 잘 가져오고 계시는 군요! 좋습니닷 다만 keyHolder.getKey()가 null 일 수 있으니, null 체크해서 에러 던지는 로직을 작성해보는 건 어떨까요?
|
|
||
| jdbcTemplate.update( | ||
| connection -> { | ||
| PreparedStatement ps = connection.prepareStatement(sql,new String[]{"id"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PreparedStatement 를 생성할 때, 두 번째 파라미터에 컬럼명을 지정해서 가져오기 보단 PreparedStatement.RETURN_GENERATED_KEYS 를 사용하면 좋을 것 같아요! 모든 자동 생성된 키를 가져올 수 있어요.
5단계 - 데이터베이스 적용하기
6단계 - 데이터 조회하기
7단계 - 데이터 추가/삭제하기