본문 바로가기

백업

[DBMS] Connection Pool 사용해보기

웹페이지에서 DBMS와 연동하여 DB에서 데이터를 입력 조회를 할 때

DBMS와 연동하기위해선 Connection객체를 생성하고 PreparedStatement 등을 이용했었다.

이전 게시물 참조

하지만, 연동 프로그램을 위해 각 페이지별로 Connection객체를 생성하는 것은 비효율적!

Pool이라는 개념으로 Connection객체를 관리하는것이 효율적이다.

WAS에 따라 자체Pool을 제공하는 것들도 있다.

 

방법) Context.xml 과 web.xml의 환경설정을 통해 Connection객체를 등록해 놓고 네이밍으로 해당 객체를 획득하여 사용할 수 있다.

 

- Context.xml

 

-web.xml

 

-ConnectionServlet.java 

 

-결과-

콘솔창에 다음과 같이....  확득한 conn = jdbc:mysql://localhost:3306/one?autoReconnect=true, UserName=root@localhost, MySQL Connector Java

 

 

'백업' 카테고리의 다른 글

[Servlet] 이벤트 리스너  (0) 2014.09.20
[Servlet] 로그인 인증시 필터 검사  (0) 2014.09.19
[Servlet] 방문자 카운트  (0) 2014.08.31
[Servlet] 로그인 아이디 기억하기  (0) 2014.08.30
[Servlet] 데이터 저장 방법  (0) 2014.08.30