[tomcat] DataSource 설정
각각 Tomcat 버전마다 차이가 있다
tomcat 5.5 버전
예제.1
context.xml에 해당 부분을 추가해준다.
<Resource name="jdbc/public" auth="Container" type="javax.sql.DataSource"
maxActive="20" maxIdle="10" maxWait="-1"
username="myid" password="mypassword" driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:ORA920"/>
[mysql]
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/mySplDB" username="test" password="test1" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useUnicode=true&characterEncoding=euckr" />
예제.2
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/tmjtest"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
url="jdbc:mysql://localhost:3306/tmjtest"
username="root"
password=""
maxActive="20"
maxIdle="10"
maxWait="-1" />
</GlobalNamingResources>
<!-- Context 만들때.. -->
<Context path="/tmj" docBase="c:\tmj" debug="0" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="tmjtest_log." suffix=".txt" timestamp="true"/>
<ResourceLink name="jdbc/tmjtest" global="jdbc/tmjtest" type="javax.sql.DataSource"/>
</Context>
[mysql]
<ResourceParams name="jdbc/ucmsDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useUnicode=true&characterEncoding=euckr</value>
</parameter>
<parameter>
<name>username</name>
<value>aaa</value>
</parameter>
<parameter>
<name>password</name>
<value>bbb</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
</ResourceParams>
'개발 > Server' 카테고리의 다른 글
Apache 2.2 + Tomcat 6 + mod_jk를 이용한 연동 ② - windows (0) | 2009.11.11 |
---|---|
[tomcat] 웹사이트 특정 IP만 접속 가능 하게하기 (0) | 2009.02.17 |
mod_jk를 이용해서 Apache, Tomcat 연동 - Windows (3) | 2008.12.27 |
Tomcat Context 추가 (0) | 2008.12.26 |
proxy모듈을 통한 Apache, Tomcat 연동 - Windows (0) | 2008.12.26 |