tomcat配置多个数据库连接池

 关于TOMCAT配置多个连接池 
如果是TOMCAT5的话
META-INF下的context.xml
对这段进行修改
<Resource
       name="jdbc/aa"
       type="javax.sql.DataSource"
       driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
       password="123456"
       maxIdle="10"
       maxWait="-1"
       username="123"
       url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=aa"
       maxActive="20"/>
添加在原来的后面就可以了,需要对参数进行适当的修改
如果是TOMCAT4的话
更改conf下server.xml
<Context path="/gdmail" reloadable="false" docBase="gdmail" >   
      <!-- 这是第一个连接池   -->
           <Resource name="jdbc/dsmail" auth="Container" type="javax.sql.DataSource"/>   
           <ResourceParams name="jdbc/dsmail">
             <parameter> 
               <name>factory</name>
               <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
             </parameter>
   <!-- DBCP database connection settings -->
      <parameter>
               <name>url</name>
               <value>jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=GB2312</value>
             </parameter>
     <parameter>
               <name>driverClassName</name>
               <value>com.mysql.jdbc.Driver</value>
            </parameter>
             <parameter>
               <name>username</name>
               <value>root</value>
             </parameter>
             <parameter>
               <name>password</name>
               <value>123456</value>
             </parameter>
    <!-- DBCP connection pooling options -->
    <parameter>
     <name>maxWait</name>
     <value>5000</value>
    </parameter>
    <parameter>
     <name>maxIdle</name>
     <value>36</value>
    </parameter>
    <parameter>
     <name>maxActive</name>
     <value>36</value>
    </parameter>
           </ResourceParams>
          
        <!-- 这是第二个连接池   -->
         <Resource name="jdbc/OracleDB" auth="Container" type="javax.sql.DataSource"/> 
         <ResourceParams name="jdbc/OracleDB"> 
         <parameter>
          <name>factory</name>
           <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
         <parameter>
          <name>url</name>
           <value>jdbc:oracle:thin:@192.168.0.10:1521:ering</value>
         </parameter>
         <parameter>
          <name>driverClassName</name>
            <value>oracle.jdbc.driver.OracleDriver</value>
         </parameter>
         <parameter>
           <name>username</name>
            <value>admin</value>
         </parameter>
         <parameter>
          <name>password</name>
           <value>123456</value>
         </parameter>
                
         <parameter> 
           <name>maxWait</name> 
             <value>1000</value> 
         </parameter> 
         <parameter> 
           <name>maxIdle</name> 
             <value>10</value> 
         </parameter> 
         <parameter>
           <name>maxActive</name>
            <value>20</value>
         </parameter> 
        </ResourceParams>
        <!-- 第二个连接池结束   -->
       </Context>

你可能感兴趣的:(tomcat,连接池,职场,休闲)