Announcement Announcement Module
Collapse
No announcement yet.
Connections to MSSQL not closing when undeploying Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Connections to MSSQL not closing when undeploying

    The problem is that everytime I undeploy my webapp the connection with the MSSQL database is not closed and when I deploy the app again a new connection is created everytime. So the connections just stack up!!

    While the app is running it behaves correctly and does not create addidional connections with the db.

    I'm running Spring 1.1 in a Tomcat 5.0.25 and connecting to a MS SQL Server

    I use ClassPathXmlApplicationContext to initate my db-class.

    Here is my context-hibernate.xml:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
      <bean id="hinDAO" class="is.ogv.mnp.db.HinHibernateDAO">
        <property name="sessionFactory">
          <ref bean="hinSessionFactory"/>
        </property>
      </bean>
    
      <!--********************************************************************************************-->
    
      <bean id="hinDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
          <value>net.sourceforge.jtds.jdbc.Driver</value>
        </property>
        <property name="url">
          <value>jdbc&#58;jtds&#58;sqlserver&#58;//dev0&#58;1433/mnp</value>
        </property>
        <property name="username">
          <value>mnp</value>
        </property>
        <property name="password">
          <value></value>
        </property>
      </bean>
    
      <!--********************************************************************************************-->
    
      <bean id="hinSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        <property name="mappingResources">
          <list>
            <value>HinObj.hbm.xml</value>
          </list>
        </property>
        <property name="hibernateProperties">
          <props>
            <prop key="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
          </props>
        </property>
        <property name="dataSource">
          <ref bean="hinDataSource"/>
        </property>
      </bean>
    
    </beans>
    any ideas?

    thanks

  • #2
    Are you calling the close() method on your application context anywhere when it shuts down, which should cause the destroy method to be called on your DataSource? In a web app you should really be using WebApplicationContext, which should close on undeploy.

    Comment


    • #3
      Thank you for the response.
      You were spot on right. The problem was that I shouldn't have been using ClassPathXmlApplicationContext. Because of that, my webapp wasn´t undeploying correctly.

      Thanks again

      Comment

      Working...
      X