Download URL
DBCP : http://commons.apache.org/dbcp/downloads.html
Pool : http://commons.apache.org/pool/downloads.html
Collection : http://commons.apache.org/downloads/download_collections.cgi
DBCP : http://commons.apache.org/dbcp/downloads.html
Pool : http://commons.apache.org/pool/downloads.html
Collection : http://commons.apache.org/downloads/download_collections.cgi
%app_dir%/WEB-INF/web.xml
----------------------------------------------------
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/jdbcTest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
%server_dir%/conf/sever.xml
----------------------------------------------------
<GlobalNamingResources>
......
<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver"
maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/jdbcTest" password="1111"
type="javax.sql.DataSource" url="jdbc:oracle:thin:@127.0.0.1:1521:testdb" username="tester" />
....
</GlobalNamingResources>
%server_dir%/context.xml
----------------------------------------------
<Context>
...
<ResourceLink global="jdbc/jdbcTest" name="jdbc/jdbcTest" type="javax.sql.DataSource" />
...
</Context>
TestDbcp.jsp
----------------------------------------------------------
<%@ page contentType="text/html;charset=euc-kr" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<%
try{
//DBCP init
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/jdbcTest");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String sql="SELECT sysdate FROM dual";
ResultSet rs = stmt.executeQuery(sql);
if (rs.next())
out.println(rs.getString("SYSDATE"));
stmt.close();
conn.close();
} catch(Exception e) {
out.println("error : " + e);
}
%>
위 설정중 빨간색은 사용자에 맞게 세팅.
마지막 테스트 코드를 실행 했을때 날짜가 나오면 성공이다.
'프로그래밍 > JSP _ Servlet _ Beans' 카테고리의 다른 글
Alice 웹 데이터 모듈... (0) | 2008.05.14 |
---|---|
Tomcat & Oracle DBCP 설정 (2) | 2008.02.04 |
Oracle Long 형 insert 에러... ORA-01461 (2) | 2007.08.03 |
JSTL(Java Standard Tag Library) 정리문서... (0) | 2007.05.02 |
JSP를 Excel 파일로 내보내는 법. (4) | 2007.03.09 |