Tomcat 6 连接池的配置比起Tomcat 5简单多了,
1,环境:
tomcat6.0.26 + db2
DB2的JDBC驱动要放到tomcat的/lib目录下的,
新建WEB项目,略过,,
我一般不把WEB项目直接部署在tomcat 的webapp下,而是修改server.xml文件,
<Context path="/test" docBase="XXXXXX" debug="0" reloadable="true">
<Resource name="jdbc/db2"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:db2://localhost:50000/XXXXXX"
username="XXXXXX"
password="XXXXXX"
maxActive="2" maxIdle="30" maxWait="10000"/>
</Context>
这样就为test项目设置好了连接池,
测试,网上的CODE太多了,略过,,
如果是为TOMCAT下的所有项目配置连接池,直接把Resource 写在conf/context.xml中,
tomcat6.X的版本,不在web.xml中设置也行,好像5的版本要设置,
<description>DB2 Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/db2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>