日期:2014-05-20 浏览次数:20894 次
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="xxxx" /> <property name="username"><value>xxxx</value></property> <property name="password"><value>xxxxx</value></property> <property name="maxActive"><value>20</value></property> <property name="initialSize"><value>1</value></property> <property name="maxWait"><value>60000</value></property> <property name="maxIdle"><value>20</value></property> <property name="minIdle"><value>3</value></property> <property name="removeAbandoned"><value>true</value></property> <property name="removeAbandonedTimeout"><value>180</value></property> <property name="connectionProperties"><value>clientEncoding=GBK</value></property> </bean>
------解决方案--------------------
C3P0的
<props> <prop key="acquireIncrement">1</prop> <prop key="initialPoolSize">1</prop> <prop key="minPoolSize">1</prop> <prop key="maxPoolSize">16</prop> <prop key="maxIdleTime">1800</prop> <prop key="maxIdleTimeExcessConnections">1000</prop> <!-- 自动收缩连接用的,单位秒--> <!-- 自动重连需要的三个参数 --> <prop key="acquireRetryAttempts">30</prop> <prop key="acquireRetryDelay">1000</prop> <prop key="breakAfterAcquireFailure">false</prop> </props>