- 오라클기준 -

- Connection Pool 사용시 기본 라이브러리

  commons-dbcp.jar
  commons-collections.jar
  commons-pool.jar

 

- 오라클 JDBC 라이브러리

  classes12.jar


- 해당 context의 server.xml을 설정.

<Resource name="jdbc/jsptest"
                  auth="Container"
                  type="javax.sql.DataSource"
                  driverClassName="oracle.jdbc.driver.OracleDriver"
                
                  loginTimeout="10"
                  maxWait="5000"
                  username="db_ID"
                  password="db_PASS"
                  testOnBorrow="true"
                  url="jdbc:oracle:thin:@127.0.0.1:1521:db_SID"

/>


- 해당 context의 web.xml을 설정.
<resource-ref>

   <description>jsptest db</description>
   <res-ref-name>jdbc/jsptest</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>


- JSP에서 호출 방법.

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/jsptest");
Connection conn = ds.getConnection();


Posted by 옴팡투덜이
BLOG main image
by 옴팡투덜이

공지사항

카테고리

분류 전체보기 (59)
감상과 비평 (15)
자기 고찰 (0)
Infomation (40)
아이디어 (0)
일탈을 꿈꾸는 나의 일상 (1)

최근에 올라온 글

최근에 달린 댓글