日期:2014-05-16  浏览次数:20540 次

Tomcat下连接池的创建及部署For DB2 ,ORACLE
1.一.Tomcat 下部署DB2连接池  
2.将db2安装目录C:\Program Files\IBM\SQLLIB\java下的common.jar,db2java.zip(改名成db2java.jar),db2jcc.jar拷贝到D:\Program Files\Tomcat 5.5\common\lib目录。  
3.修改D:\Program Files\Tomcat 5.5\conf下server.xml  
4.注意两个地方的内容:  
5.     <Resource name="jdbc/szfood" auth="Container"  
6.              type="javax.sql.DataSource" driverClassName="COM.ibm.db2.jdbc.net.DB2Driver"  
7.              url="jdbc:db2://localhost:6789/SZFOOD"  
8.              username="fuser" password="szfood0755" maxActive="20" maxIdle="10"  
9.              maxWait="-1"/>   
10.  
11.    <Context  docBase="E:\JAVA\WFStudy\szfood\WebRoot"  path=""  reloadable="true" >  
12.           <ResourceLink global="jdbc/szfood" name="jdbc/szfood" type="javax.sql.DataSource"/>  
13.        </Context>  
14.  
15.二.Tomcat下部署ORACLE连接池  
16.将oracle安装目录C:\oracle\product\10.2.0\db_1\jdbc\lib\classes12.jar拷贝到D:\Program Files\Tomcat 5.5\common\lib目录。  
17.修改D:\Program Files\Tomcat 5.5\conf下server.xml  
18.注意两个地方的内容:  
19.     <Resource name="jdbc/oracleds" auth="Container"  
20.              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"  
21.              url="jdbc:oracle:thin:@127.0.0.1:1521:LWF"  
22.              username="scott" password="tiger" maxActive="100" maxIdle="30"  
23.              maxWait="10000"/>   
24.  
25.    <Context  docBase="C:\Documents and Settings\zqwf\workspace\Struts\WebRoot"  path="/Struts"  reloadable="true" >  
26.           <ResourceLink global="jdbc/oracleds" name="jdbc/oracleds" type="javax.sql.DataSource"/>  
27.        </Context>  

以下是示例server.xml文件内容:
1.<!-- Example Server Configuration File -->  
2.<!-- Note that component elements are nested corresponding to their  
3.     parent-child relationships with each other -->  
4.  
5.<!-- A "Server" is a singleton element that represents the entire JVM,  
6.     which may contain one or more "Service" instances.  The Server  
7.     listens for a shutdown command on the indicated port.  
8.  
9.     Note:  A "Server" is not itself a "Container", so you may not  
10.     define subcomponents such as "Valves" or "Loggers" at this level.  
11. -->  
12.  
13.<Server port="8005" shutdown="SHUTDOWN">  
14.  
15.  <!-- Comment these entries out to disable JMX MBeans support used for the   
16.       administration web application -->  
17.  <Listener className="org.apache.catalina.core.AprLifecycleListener" />  
18.  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />  
19.  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />  
20.  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>  
21.  
22.  <!-- Global JNDI resources -->  
23.  <GlobalNamingResources>  
24.  
25.    <!-- Test entry for demonstration purposes -->  
26.    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>  
27.  
28.    <!-- Editable user database that can also be used by  
29.         UserDatabaseRealm to authenticate users -->  
30.    <Resource name="UserDatabase" auth="Container"  
31.              type="org.apache.catalina.UserDatabase"  
32.       description="User database that can be updated and saved"  
33.           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  
34.          pathname="conf/tomcat-users.xml" />  
35.     <Resource name="jdbc/oracleds" auth="Container"  
36.              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"  
37.              url="jdbc:oracle:thin:@127.0.0.1:1521:LWF"  
38.              username="scott" password="tiger" maxActive="100" maxIdle="30"  
39.              maxWait="10000"/>   
40.    <Resource name="jdbc/szfood" auth="Container"  
41.