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

tomcat的数据库连接池(方法二)


1.配置tomcat下的conf下的context.xml文件,在<context></context>之间添加连接池如下:
<Resource name="jdbc/mysql" 
       auth="Container" 
         
       type="javax.sql.DataSource" 
       driverClassName="com.mysql.jdbc.Driver" 
       url="jdbc:mysql://localhost/test" 
       username="root" 
       password="root" 
       maxActive="100" 
       maxIdle="30" 
       maxWait="10000" /> 
                  

2.配置你的应用下的web.xml中的<web-app></web-app>之间加入:
xml 代码
<resource-ref> 
    <description>DB Connection</description> 
    <res-ref-name>jdbc/mysqlx</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
  </resource-ref>