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);
}
%>
위 설정중 빨간색은 사용자에 맞게 세팅.
마지막 테스트 코드를 실행 했을때 날짜가 나오면 성공이다.
trackback from: Tomcat & Oracle DBCP 설정
답글삭제Download URLDBCP : http://commons.apache.org/dbcp/downloads.htmlPool : http://commons.apache.org/pool/downloads.htmlCollection : http://commons.apache.org/downloads/download_collections.cgi pool.jocl <object class="org.apache.commons.dbcp.PoolableCon..