|
Java 입문공부중에 느껴지는 의문과 그에 대한 해결(?)
JDBC에서 사용하는 PreparedStatement와 CallableStatement는 Query를 최적화하여 사용한다고 되어있다. 예제코드에서는 ... PreparedStatement pstmt = conn.prepareStatement("...?... "); pstmt.set...(..., ...); pstmt.execute...(); ... 이런식으로 되어있었다. 여기서 들었던 의문은, Connection instance에서 prepareStatement("...");를 실행한 후 return된 PreparedStatement instance를 어떻게든 Application에서 저장해서 다시 사용해야하지 않을까 하는 것이었다. 그런데... 딱히 찾아봐도 그런식으로 구현된 예제는 하나도 없었다..ㅠ0ㅠ (검색어 : Connection prepareStatement) 그러면, Connection instance가 prepareStatement("...");를 실행하여 PreparedStatement의 instance를 return할 때, connection의 instance 내에 PreparedStatement의 instance를 저장하고 있다가, 동일한 "..."의 요청이 있으면 그것을 return?하는 것일까?? 그런데, 그렇다고 생각하기에는 connection의 instance가 생성되고 삭제되는것이 너무 빈번하게 일어났다. (일반 application에서는 아니지만, web application에서는 그렇다!!) 다시 검색한 결과!!! 완전 해결..ㅠ0ㅠ (검색어 : Connection prepareStatement cache) 영문기사 : http://www.theserverside.com/articles/article.tss?l=Prepared-Statments 해석 : http://wasservice.net/board/zboard.php?id=DataBase&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=name&desc=asc&no=6 해석이 그렇게까지 잘 되었다고 생각되지는 않지만, 기술문서의 번역이 언제나 그렇듯이... 결론은 DriverManager에 의해 생성되는 것이 실제 DB Connection이 아니라, Wrapping된 Connection이라는 것이었다. 그리고, PreparedStatement과 같이 cache가 필요한 것은 Server의 Connection Pool내에 저장되었다가, 요청이 들어오면 cache되어있는 것을 return한다는 것이었다..ㅠ0ㅠ
|
by 나무귀신 카테고리
최근 등록된 덧글
ㅎㅎ 이제 사서 읽기시..
by 이라나이 at 10/31 저도 Jericho보다가 궁.. by ㅁㄴㅇ at 03/22 아... 이 책. 손에 잡.. by simsen at 03/01 컥 그냥 프로세스만 잡.. by nuka at 02/22 to 마네킹 삼성과의 마.. by 나무귀신 at 11/15 삼성이 김변호사의 패를.. by 나무귀신 at 11/15 최근 등록된 트랙백
Adderall.
by Adderall without a pr.. Diazepam onset. by 60 mg diazepam alco.. Adderall. by Adderall 7.5 image. Oracle Table Alias .. by 행복의 세잎 클로버 라이프로그
태그
|