Results 1 to 3 of 3

Thread: Connections to MSSQL not closing when undeploying

  1. #1
    Join Date
    Sep 2004
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Sep 2004
    Posts
    2

    Default

    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

Similar Threads

  1. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  2. Replies: 2
    Last Post: Apr 14th, 2005, 11:02 AM
  3. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  4. Replies: 1
    Last Post: Nov 17th, 2004, 08:21 AM
  5. Replies: 3
    Last Post: Sep 29th, 2004, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •