Tomcat DBCP配置方法
2009-09-26 00:00:00 来源:WEB开发网第二步:修改C:"eclipse-SDK-3.0.1-win32"eclipse"workspace"zlp"WebContent"WEB-INF下web.xml,在<web-app>…..</web-app>中增加一级元素如下:
<!-- Database Config start -->
<resource-ref>
<description>connectDB test</description>
<res-ref-name>jdbc/testdb0_cs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- Database Config end -->
说明:蓝色的路径是你的应用所在路径下的web.xml
第三步:将Informix JDBC Driver拷贝到C:"Tomcat 5.0"common"lib目录下
第四步:重新启动tomcat
二、Tomcat中配置多个数据源的方法
第一步:server.xml 蓝色和绿色部分是两个数据源,分别连接两个不同的数据库。依次类推,配置多个。
<DefaultContext>
<Resource name="jdbc/testdb0_cs1" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/testdb0_cs1">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://192.177.179.208:6666/testdb0_cs1:INFORMIXSERVER=ccbhr_test</value>
</parameter>
<parameter>
<name>username</name>
<value>informix</value>
</parameter>
<parameter>
<name>password</name>
<value>google</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>poolPrepareStatements</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<!-- Abandoned DB connections are removed and recycled -->
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<!-- Use the removeAbandonedTimeout parameter to set the number of seconds a DB connection has been idle before it is considered abandoned. -->
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<!-- Log a stack trace of the code which abandoned -->
<value>false</value>
</parameter>
</ResourceParams>
<Resource name="jdbc/testdb0_cs" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/testdb0_cs">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://192.177.191.130:6666/testdb0_cs:INFORMIXSERVER=ccbhr_test</value>
</parameter>
<parameter>
<name>username</name>
<value>informix</value>
</parameter>
<parameter>
<name>password</name>
<value>informix</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>poolPrepareStatements</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<!-- Abandoned DB connections are removed and recycled -->
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<!-- Use the removeAbandonedTimeout parameter to set the number of seconds a DB connection has been idle before it is considered abandoned. -->
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<!-- Log a stack trace of the code which abandoned -->
<value>false</value>
</parameter>
</ResourceParams>
</DefaultContext>
- ››配置MySQL出错The service could not be started....
- ››配置apache虚拟主机
- ››配置远程客户机使用命名管道协议访问SQL服务器
- ››配置SQL Server2005以允许远程访问
- ››配置ISA Server以创建站点到站点VPN 连接之一
- ››配置ISA Server以创建站点到站点VPN 连接之二
- ››配置ISA Server以创建站点到站点VPN 连接之三 启用...
- ››配置VPN服务器中的L2TP/IPSEC:ISA2006系列之二十...
- ››配置单网卡的ISA缓存服务器:ISA2006系列之二十七...
- ››配置Win2008作为远程访问SSL-VPN服务器之一
- ››配置Win2008作为远程访问SSL-VPN服务器之二
- ››配置Win2008作为远程访问SSL-VPN服务器之三
更多精彩
赞助商链接