Announcement Announcement Module
No announcement yet.
Connections to MSSQL not closing when undeploying Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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:

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


  • #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.


    • #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