连接池

常见连接池Tomcat-dbcp、dbcp、c3p0、druid

可以用数据源(java.sql.DataSource)管理连接池

Tomcat-dbcp:

a.类似jndi 在 context.xml中配置数据库

<Environment name="student" value="jndiValue" type="java.lang.String"/>
    
       <Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource" 
                 maxActive="400" maxIdle="20" maxWait="5000" 
                 username="root" password="123456" driverClassName="com.mysql.jdbc.Driver" 
                 url="jdbc:mysql://localhost:3306/test?autoReconnect=true"/>  

b.项目中web.xml中配置

<resource-ref>
        <res-ref-name>student</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
原文地址:https://www.cnblogs.com/mzdljgz/p/11062760.html