连接池泄露的问题
先贴代码:1,应用一datasource配置
<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@192.168.249.50:1521:orcl"/>
<property name="username" value="skxt"/>
<property name="password" value="skxt"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="ds" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.dialect">com.eka.util.MyDialect</prop>
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.c3p0.max_size">50</prop>
<!-- 获得连接的超时时间,如果超过这个时间,会抛出异常,单位毫秒 -->
<prop key="hibernate.c3p0.timeout">1000</prop>
<!-- 最大的PreparedStatement的数量 -->
<prop key="hibernate.c3p0.max_statements">100</prop>
<!-- 当连接池里面的连接用完的时候,C3P0一下获取的新的连接数 -->
<prop key="hibernate.c3p0.acquire_increment">2</prop>
<!-- 每隔120秒检查连接池里的空闲连接 ,单位是秒-->
<prop key="hibernate.c3p0.idle_test_period">120</prop>
<!-- 每次都验证连接是否可用 -->
<prop key="hibernate.c3p0.validate">false</prop>
</props>
</property>
</bean>
2,应用一webservice调用
webservice使用的是spring-xfire
<!-- xfire相关配置 -->
<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations" lazy-init="false" />
<bean id="jsr181HandlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping" lazy-init="false">
<property name="xfire" ref="xfire" />
<property name="webAnnotations" ref="webAnnotations" />
</bean>
<!-- end xfire -->
3,应用二 datasource配置:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@192.168.249.50:1521:orcl">
</property>
<property name="username" value="netpay_0407" />
<property name="password" value="netpay_0407" />
</bean>
4,应用二 webserivice配置
<!-- xfire相关配置 -->
<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations" lazy-init="false" />
<bean id="jsr181HandlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping" lazy-init="false">
<property name="xfire" ref="xfire" />
<property name="webAnnotations" ref="webAnnotations" />
</bean>
<!-- end xfire -->
@Component
@WebService(serviceName = "financeService", endpointInte易做图ce = "com.elis.finance.webService.IFinanceManager")
public class FinanceManager implements IFinanceManager {
@Autowired
private PropJournalServiceImpl propJournalServiceImpl;
@Autowired
private BisJournalFileDirectProcess bisJournalFileDirectProcess;
public String uploadVoucherToBis(String xml) {
//调用应用二的数据库
mapper.proCreateSumVoucher();
}
}
应用二的mapper调用:
public inte易做图ce SettleCoreVoucherFileMapper {
public List<ParseFileResultDTO> proCreateSumVoucher(String type);
说明:应用一是spring1.2+hibernate3,应用二是spring3x+myibatis,现在的情况是应用一,应用二单独使用没有任何问题(或者没有发现问题),当应用一使用webservice调用应用二的方法,一段时间后或者持续并发调用后,应用一出现线程池爆膨,其他功能无法连接到数据库(处于等待状态),webservice还是可以继续调用,使用正常,当在datasource配置上添加destory方法后,问题得到解决(或者伪解决),有没有人能够帮忙看看!
xfire 连接池 webservice
补充:Java , Java EE