那位高手可以帮解答下这个问题?
问题描述如下:
 select machine, count(*)as cnt,status 
  from v$session
 where username = 'SR'
 and status = 'INACTIVE'
 group by machine,status 
 order by cnt desc;
  
1 CRMAPP3 393 INACTIVE
2 CRMAPP4 305 INACTIVE
3 CRMAPP2 235 INACTIVE
4 CRMAPP1 4 INACTIVE出现的连接数非常多,但是程序里面连接数据库是通过spring的配置文件连接的。请高手帮看看,这个配置文件之前一直没有动过。
 
  <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jsbss.properties</value>
</list>
</property>
</bean>
<!--数据库连接-->
<bean id="storeDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>${storeDatabase}</value>
</property>
<property name="username">
<value>${storeUser}</value>
</property>
<property name="password">
<value>${storeUserPwd}</value>
</property>
<property name="maxActive">
<value>${maxActive}</value>
</property>
<property name="maxIdle">
<value>${maxIdle}</value>
</property>
<property name="minIdle">
<value>${minIdle}</value>
</property>
<property name="initialSize">
  <value>${initialSize}</value>
</property>
</bean>
<bean id="crmJDBC"
class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="storeDataSource" />
</constructor-arg>
</bean>
<!--数据库事务控制-->
<bean id="crmTransaction" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="storeDataSource"/>
</property>
</bean>
<bean id="crmTxAttributes" class="org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource">
<property name="transactionAttribute">
<value>PROPAGATION_REQUIRED,-Exception,-bss.common.DAOException</value>
</property>
</bean>
<bean id="crmTxInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref local="crmTransaction" />
</property>
<property name="transactionAttributeSource">
<ref local="crmTxAttributes" />
</property>
</bean>
<bean id="crmAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<value>crmTxInterceptor</value>
</property>
<property name="beanNames">
<list>
<value>*DAO</value>
<value>*Manager</value>
</list>
</property>
</bean>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor">
<ref local="nativeDbcpJdbcExtractor" />
</property>
</bean>
<bean id="nativeDbcpJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" />
<!--DAO注入-->
<bean id="operateTreeDAO" class="bss.crm.saleresource.dao.impl.OperateTreeDAOImpl">
<property name="crmJdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="storeAssitDAO" class="bss.crm.saleresource.dao.impl.StoreAssitDAOImpl">
<property name="jdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="storeInoutDAO" class="bss.crm.saleresource.dao.impl.StoreInoutDAOImpl">
<property name="jdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="materialManagerDAO" class="bss.crm.saleresource.dao.impl.MaterialManagerDAOImpl">
<property name="crmJdbc">
<ref bean="crmJDBC" />
</property>
<property name="operateTreeDAO">
<ref bean="operateTreeDAO"/>
</property>
</bean>
<bean id="storeManagerDAO" class="bss.crm.saleresource.dao.impl.StoreManagerDAOImpl">
<property name="crmJdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="applyDAO" class="bss.crm.saleresource.dao.impl.ApplyDAOImpl">
<property name="jdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="inOutDAO" class="bss.crm.saleresource.dao.impl.InOutDAOImpl">
<property name="jdbc">
<ref bean="crmJDBC" />
</property>
<property name="lobHandler">
<ref bean="oracleLobHandler" />
</property>
<!--<property name="vcServiceIp">
    <value>${valueCardServiceIp}</value>
</property>
--></bean>
<bean id="batchBusiDao" class="bss.crm.saleresource.dao.impl.BatBusiDaoImpl">
<property name="jdbcTemplate">
<ref bean="crmJDBC" />
</property>
<property name="lobHandler">
<ref bean="oracleLobHandler" />
</property>
<property name="storeInoutDAO">
<ref bean="storeInoutDAO" />
</property>
</bean>
<bean id="repairDAO" class="bss.crm.saleresource.dao.impl.RepairDAOImpl">
<property name="jdbc">
<ref bean="crmJDBC" />
</property>
</bean>
<bean id="inoutStorePrintDAO" class="bss.crm.saleresource.dao.impl.InoutStorePrintDAOImpl">
    <property name="jdbc">
        <ref  bean = "crmJDBC"/>
    </property>
</bean> <!--BMO注入-->
<bean id="operateTreeManager" class="bss.crm.saleresource.bmo.impl.OperateTreeImpl">
<property name="operateTreeDAO">
<ref bean="operateTreeDAO"/>
</property>
</bean>
<bean id="storeAssitManager" class="bss.crm.saleresource.bmo.impl.StoreAssitManagerImpl">
<property name="storeInoutDAO">
<ref bean="storeInoutDAO" />
</property>
<property name="storeAssitDAO">
<ref bean="storeAssitDAO" />
</property>
<!--<property name="inOutDAO">
<ref bean="inOutDAO"/>
</property>
--></bean>
<bean id="applyManager" class="bss.crm.saleresource.bmo.impl.ApplyManagerImpl">
<property name="storeInoutDAO">
<ref bean="storeInoutDAO"/>
</property>
<property name="applyDAO">
<ref bean="applyDAO"/>
</property>
</bean>
<bean id="inOutManager" class="bss.crm.saleresource.bmo.impl.InOutManagerImpl">
<property name="storeInoutDAO">
<ref bean="storeInoutDAO"/>
</property>
<property name="applyDAO">
<ref bean="applyDAO"/>
</property>
<property name="inOutDAO">
<ref bean="inOutDAO"/>
</property>
</bean>
<bean id="materialManager" class="bss.crm.saleresource.bmo.impl.MaterialManagerImpl">
<property name="materialManagerDAO">
<ref bean="materialManagerDAO"/>
</property>
<!--<property name="storeInoutDAO">
<ref bean="storeInoutDAO" />
</property>
--></bean>
<bean id="storeManager" class="bss.crm.saleresource.bmo.impl.StoreManagerImpl">
<property name="storeManagerDAO">
<ref bean="storeManagerDAO"/>
</property>
</bean>
<bean id="batchBusiManager" class="bss.crm.saleresource.bmo.impl.BatchBusiManagerImpl">
<property name="batchBusidao">
<ref bean="batchBusiDao" />
</property>
</bean>
<!--<bean id="repairManager" class="bss.crm.saleresource.bmo.impl.RepairManagerImpl">
<property name="repairDAO">
<ref bean="repairDAO"/>
</property>
<property name="storeInoutDAO">
<ref bean="storeInoutDAO" />
</property>
</bean>

--><bean id="jndiRSC" class="org.springframework.jndi.JndiTemplate">
<constructor-arg>
<props>
<prop key="java.naming.factory.initial">${NamingInitFactoryClass}</prop>
<prop key="java.naming.provider.url">${jndiRSC}</prop>
</props>
</constructor-arg>
</bean>
<bean id="jndiCO" class="org.springframework.jndi.JndiTemplate">
<constructor-arg>
<props>
<prop key="java.naming.factory.initial">${NamingInitFactoryClass}</prop>
<prop key="java.naming.provider.url">${jndiCO}</prop>
</props>
</constructor-arg>
</bean>
<bean id="rscService" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true">
<property name="jndiName">
<value>bss/resourcemanager/provide/RscService</value>
</property>
<property name="lookupHomeOnStartup">
<value>false</value>
</property>
<property name="refreshHomeOnConnectFailure">
<value>true</value>
</property>
<property name="jndiTemplate">
<ref local="jndiRSC" />
</property>
<property name="businessInterface">
<value>bss.crm.invoke.rsc.RscInvoke</value>
</property>
</bean>
<bean id="initSessionHttp" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl">
<value>${sm.initSessionUrl}</value>
</property>
<property name="serviceInterface">
<value>bss.crm.saleresource.session.init.IsessionInit</value>
</property>
</bean> 
<!-- 税控接口  -->
<bean id="infoSyncManager" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true">
<property name="jndiName">
<value>com/linkage/crm/infoservice/ejb/InfoSyncManager</value>
</property>
<property name="lookupHomeOnStartup">
<value>false</value>
</property>
<property name="refreshHomeOnConnectFailure">
<value>true</value>
</property>
<property name="jndiTemplate">
<ref local="jndiCO" />
</property>
<property name="businessInterface">
<value>com.linkage.crm.infoservice.bmo.InfoSyncManager</value>
</property>
</bean>
<bean id="printManager" class="bss.crm.saleresource.bmo.impl.PrintManagerImpl">
     <property name="printDao">
         <ref bean="inoutStorePrintDAO"/>
     </property>
     <property name="applyDAO">
<ref bean="applyDAO"/>
</property>
<property name="invoiceManager">
         <ref bean="infoSyncManager"/>
     </property>
</bean>
</beans>

解决方案 »

  1.   

    <property name="minIdle">
    <value>${minIdle}</value>
    </property>
    <property name="initialSize">
    <value>${initialSize}</value>
    </property>这两个值是否设置的太高了,上面这个是指最小的空闲数,后面一个是初始化的时候产生多少数量
      

  2.   

    那么长篇幅???
    配置文件中设置的连接数是定的,只是你查询查来连接数很多,
    看看你程序中是否每次释放连接了 connect.close
      

  3.   

    问题是数据库只放在配置文件里面进行spring的管理,java代码中是不涉及数据库连接之类的操作的。一般是由于什么原因导致这种情况,后果会导致什么,请高手解答!
      

  4.   


    到J2EE版块去问下呢?
    我好久没碰过SSH了,菜鸟了。