Tomcat连接池配置方法.txt

来源:互联网 发布:php魔方加密在线解密 编辑:程序博客网 时间:2024/05/16 14:27
tomca使用连接池一般步骤(Tomcat 5.5.x 中的连接池配置和Tomcat 5.0.x中有了较大变化,这里说Tomcat5.5.x)
1.首先把mysql驱动放在$CATALINA_HOME/common/lib下面
2.在server.xml中配置的步骤是在host之前配置<Context crossContext="true" debug="5" docBase="DBCPdemo"


                    path="/DBCPdemo" reloadable="true">


        <Resource name="jdbc/TestDB"


                type="javax.sql.DataSource" auth="Container"


                driverClassName="com.mysql.jdbc.Driver" maxActive="100"


                maxIdle="30" maxWait="10000"                url="jdbc:mysql://localhost:3306/test?autoReconnect=true"


                username="root" password="root" />


</Context>
3.在web.xml配置代码是 <resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4.代码测试
原创粉丝点击