티스토리 뷰
출처 : http://blog.bagesoft.com/725
http://fallacy.tistory.com/76
http://kwon37xi.egloos.com/2852803?89a004e0
1) C:\apache-tomcat-5.5.27\conf\server.xml 내용추가
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:127.0.0.1:1521:orcl"
username="scott" password="tiger" maxActive="20" maxIdle="10"
maxWait="-1"/>
2) C:\apache-tomcat-5.5.27\conf\context.xml 내용추가
<ResourceLink global="jdbc/myoracle" name="jdbc/myoracle" type="javax.sql.DataSource"/>
3) C:\oracle\product\10.2.0\db_1\jdbc\lib 폴더의 ojdbc14.jar 파일을 C:\apache-tomcat-5.5.27\common\lib 폴더에 복사
4) C:\apache-tomcat-5.5.27\webapps\ROOT\WEB-INF\web.xml 내용 추가
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
5) Tomcat 재실행
6) 테스트 JSP 파일 작성
<%@ page import="java.sql.*, javax.naming.*, javax.sql.*"%>
<%
Context initCtx = new InitialContext();
/*
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
*/
DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/myoracle");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = ds.getConnection();
stmt = conn.createStatement();
String query = "select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') from dual"; // 현재 시간을 구하는 query
rs = stmt.executeQuery(query);
if(rs.next()) {
out.println("<br>" + rs.getString(1));
}
} catch (Exception e) {
out.println("<br>" + e.toString());
} finally {
if (rs!=null) try { rs.close(); } catch (Exception e) { }
if (stmt!=null) try { stmt.close(); } catch (Exception e) { }
if (conn!=null) try { conn.close(); } catch (Exception e) { }
}
%>
- Total
- Today
- Yesterday
- SAS
- flex
- android
- KOBA
- Delphi Tip
- 전예희
- ffmpeg
- NDK
- 송주경
- Spring MVC
- Linux
- Spring
- Mac
- BPI-M4
- koba2010
- 레이싱모델 익스트림 포토 페스티벌
- JavaScript
- 동경
- 서울오토살롱
- oracle
- ble
- Java
- 튜닝쇼 2008
- Xcode
- MySQL
- 일본여행
- sas2009
- Delphi
- 지스타2007
- ubuntu
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |