강의

멘토링

커뮤니티

Inflearn Community Q&A

ksk1004zz2515's profile image
ksk1004zz2515

asked

Spring for Beginners - Learn Spring Boot, Web MVC, and DB Access Technology with Code

Course Introduction

안녕 하세요 궁금한게 있습니다

Written on

·

215

0

resultset, statement, connection을 역순으로 해제해야 하는 이유가 무엇인가요?

connection을 해제하면 statement가 해제되고

statement가 해제되면 resultset도 해제되는데요

connection, statement, resultset 순서대로 해제해도 되고

자유롭게 할 수 있는거 아닌가요?

물론 각자의 close역할에 충실해야 하고 statement로 resultset을 close해주더라도 잘못될 가능성이 있어보이긴 하고

close된 것을 또 close할 경우 문제가 있긴 하지만요

 

그래서 close할 때 resultset -> statement -> connection 역순이 아니라

connection -> statement -> resultset으로 순서대로 해도 문제가 없어 보여서 질문 드립니다

 

MVCspringjavaspring-boot

Answer 1

1

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 하하호호님

각각 자유롭게 생성되는 것이 아니어서 그렇습니다.

connection을 통해서 statement가 생성되고, statement를 통해서 resultset이 생성되기 때문에 역순으로 리소스를 해제하는 것이 안전합니다.

감사합니다.

ksk1004zz2515's profile image
ksk1004zz2515

asked

Ask a question