conf/server.xml 파일에 데이터소스를 설정하고 JDBC 드라이버는 lib 디렉토리에 복사해야 한다.
아파치 더비
<Context ...>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:db;create=true" />
</Context>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:db;create=true" />
</Context>
JDBC 드라이버 : derby.jar
* 외부에서도 아파치 더비에 접근하려면 derbynet.jar 파일도 복사해야 한다.
오라클
<Context ...>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:db" />
</Context>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:db" />
</Context>
JDBC 드라이버 : ojdbc14.jar
DB2
<Context ...>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://127.0.0.1:50000/db" />
</Context>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://127.0.0.1:50000/db" />
</Context>
JDBC 드라이버 : db2jcc.jar, db2jcc_license_cu.jar
MS SQL 2005
<Context ...>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://127.0.0.1:1433;databaseName=db" />
</Context>
<Resource name="jdbc/Base" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000" username="username" password="password"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://127.0.0.1:1433;databaseName=db" />
</Context>
JDBC 드라이버 : 자바 1.6을 사용하면 sqljdbc4.jar, 자바 1.5를 사용하면 sqljdbc.jar
web.xml 파일 수정
이 설정이 끝나면 web.xml 파일에 다음 내용을 추가한다.
<resource-ref>
<description>Base DB Connection</description>
<res-ref-name>jdbc/Base</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<description>Base DB Connection</description>
<res-ref-name>jdbc/Base</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
* jsp-config 태그 다음에 추가한다. 일반적으로 거의 마지막에^^
No comments:
Post a Comment