캠핑과 개발


각각 Tomcat 버전마다 차이가 있다

tomcat 5.5 버전

예제.1
context.xml에 해당 부분을 추가해준다.
[oracle]
<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&amp;useUnicode=true&amp;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]
<Resource name="jdbc/ucmsDB" auth="Container" type="javax.sql.DataSource"/>
  <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&amp;useUnicode=true&amp;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>