配置文件如下:
<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.1.254:1521:RHD"></property>
<property name="username" value="rhdidentify"></property>
<property name="password" value="rhdidentify"></property>
<property name="maxActive" value="10"></property>
<property name="maxIdle" value="5"></property>
<property name="maxWait" value="1000"></property>
<property name="minIdle" value="1"></property>
<property name="testOnBorrow" value="true"></property>
<property name="testOnReturn" value="true"></property>
<property name="testWhileIdle" value="true"></property>
<property name="validationQuery" value="select 1 from dual"></property>
</bean>
不停的刷新页面,刷新多少次就创建了多少个连接。且没有释放掉?这是怎么回事呢?

解决方案 »

  1.   

    日志: 
    2010-03-19 17:03:45  executing flush
    2010-03-19 17:03:45  post flush
    2010-03-19 17:03:45  Closing Hibernate Session
    2010-03-19 17:03:45  closing session
    2010-03-19 17:03:45  closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    2010-03-19 17:03:45  after transaction completion
    2010-03-19 17:03:45  after transaction completion
    2010-03-19 17:03:45  Removed value [org.springframework.orm.hibernate3.SessionHolder@1eb41d6] for key [org.hibernate.impl.SessionFactoryImpl@5bfbd8] from thread [http-8888-2]
    2010-03-19 17:03:45  Closing single Hibernate Session in OpenSessionInViewFilter
    2010-03-19 17:03:45  Closing Hibernate Session
    2010-03-19 17:03:45  closing session
      

  2.   

    楼主如何得知刷新页面就创建连接了?那还要dbcp做啥?
      

  3.   

    并且没有抛出任何异常,但是在oracle企业管理器里面查看会话几十个会话 很恐怖。。并且会话状态是inactive
      

  4.   

    <property name="maxWait" value="5"></property>
    这个属性改小点
      

  5.   

    在oracle企业管理器里看会话数量
      

  6.   

    自己顶下
    另外也配置了openSessionInViewFilter
    <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    <init-param>
    <param-name>sessionFactory</param-name>
    <param-value>sessionFactory</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    让人很奇怪啊
      

  7.   

    把<filter-name>hibernateFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>去掉
      

  8.   

    问题解决了 有一个DAO中的分页查询直接通过getSession获取的Session且没有显式的关闭。所以导致了此问题