c3p0和dbcp的区别

c3p0dbcp区别:   
dbcp没有自动的去回收空闲连接的功能  c3p0有自动回收空闲连接功能  
两者主要是对数据连接的处理方式不同!C3P0提供最大空闲时间,DBCP提供最大连接数。 
前者当连接超过最大空闲连接时间时,当前连接就会被断掉。DBCP当连接数超过最大连接数时,所有连接都会被断开。

 

      <bean id="dataSource2" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">

        <property name="driverClassName" value="${jdbc.driverClassName}"/>

        <property name="url" value="${jdbc.url}"/>

        <property name="username" value="${jdbc.username}"/>

        <property name="password" value="${jdbc.password}"/>

        

        <property name="initialSize" value="5"/>

        

        <property name="maxActive" value="30"/>

        

        <property name="maxIdle" value="20"/>

        

        <property name="minIdle" value="3"/>

          

        <property name="removeAbandoned" value="true" />

          

        <property name="removeAbandonedTimeout" value="200"/>

         

        <property name="logAbandoned" value="true"/>

          

        <property name="maxWait" value="100"/>  

      bean>

      

    

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

        <property name="jdbcUrl" value="${jdbc.url}" />

        <property name="driverClass" value="${jdbc.driverClassName}" />

        <property name="user" value="${jdbc.username}" />

        <property name="password" value="${jdbc.password}" />

        

        <property name="maxPoolSize" value="100" />

        

        <property name="minPoolSize" value="1" />

        

        <property name="initialPoolSize" value="10" />

        

        <property name="maxIdleTime" value="30" />

        

        <property name="acquireIncrement" value="5" />

        

        <property name="maxStatements" value="0" />

         

        

        <property name="idleConnectionTestPeriod" value="60" />

         

        

        <property name="acquireRetryAttempts" value="30" />

        

        

        <property name="breakAfterAcquireFailure" value="true" />

         

        

        <property name="testConnectionOnCheckout"  value="false" />        

    bean>

你可能感兴趣的:(jdbc池)