jakarta-tomcat-5.5.7
1.web.xml的設置
<resource-ref>
??<description>OPDB JNDI for TOMCAT</description>
??<res-ref-name>jdbc/opdb</res-ref-name>
??<res-type>javax.sql.DataSource</res-type>
??<res-auth>Container</res-auth>
?</resource-ref>
2.cof/server.xml的配置(eg:C:\jakarta-tomcat-5.5.7\conf)。
<Resource name="jdbc/opdb" auth="Steve" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@172.16.208.190:1522:opdb" username="test" password="oracle" maxActive="20" maxIdle="10" maxWait="10000"/>?
3.web/META-INF/content.xml的配置。
<?xml version='1.0' encoding='utf-8'?>
<Context>
?<!-- note: the following resource name is set up to use the inet jdbc driver.? If you are
??using a different driver, then you will have to change the driverClassName.
??You will have to change the url (the ip and db identifier part), username and password
??entries for your environment.
??-->
?<Resource name="jdbc/opdb" auth="Container" type="javax.sql.DataSource" username="test" password="oracle"
??driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@172.16.208.190:1522:opdb" maxActive="20" maxIdle="10"
??maxWait="-1" validationQuery="SELECT 1 FROM DUAL"/>
</Context>
說明:我的tomcat版本是5.5.7。好像必須配置content.xml文件,但是配了這個文件,server.xml中的設置不起作用了。下面是各參數的說明:
driveClassName:JDBC驅動類的完整的名稱;
maxActive:同時能夠從連接池中被分配的可用實例的最大數;
maxIdle:可以同時閑置在連接池中的連接的最大數;
maxWait:最大超時時間,以毫秒計;
password:用戶密碼;
url:到JDBC的URL連接;
user:用戶名稱;
validationQuery:用來查詢池中空閑的連接。