특별한딸기이야기

jdbc 설정 관련 본문

딸기 공부방/웹프로그래밍

jdbc 설정 관련

특별한녀석 2008. 11. 30. 20:54
DBCP에 관한 정보 설정

server.xml

<GlobalNamingResource>
...
<Resource name="jdbc/테이블명"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
loginTimeout="10"
maxWait="5000"
username="디비접속아이디"
password="디비접속비밀번호"
testOnBorrow="true"
url="jdbc:mysql://localhost:3306/테이블명"
/>
...
</GlobalNamingResource>
...
<host>
...
<Context path="/프로젝트명" docBase="톰캣경로\webapps\프로젝트명" debug="1" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_테이블명_log." suffix=".txt" timestamp="true" />
<Resource name="jdbc/db명"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
loginTimeout="10"
maxWait="5000"
username="디비접속아이디"
password="디비접속비밀번호"
testOnBorrow="true"
url="jdbc:mysql://localhost:3306/db명"
/>
</context>
</host>
...

web.xml

<resource-rdf>
<description>
디비설명
</description>
<res-ref-name>
server.xml의 <Resource>태그의 name과 일치
</res-ref-name>
<res-type>
server.xml의 <Resource>태그의 type과 일치
</res-type>
<res-auth>
server.xml의 <Resource>태그의 auth과 일치
</res-auth>
</resource-ref>

jsp page
<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*" %>
...
try
{
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/db명);
Connection conn = ds.getConnection();
}
...

'딸기 공부방 > 웹프로그래밍' 카테고리의 다른 글

jdbc 한글 처리  (0) 2008.12.03
로컬 DB 초기 설정  (0) 2008.11.21
PreparedStatement  (0) 2008.11.14
mysql 설명 관련 블로그  (0) 2008.11.14
인터넷특론 수업자료  (0) 2008.09.25