1 Reply Latest reply on Mar 21, 2008 1:10 AM by jaikiran pai

    Jboss connection pool doesn't release the connections

    Luciano Molinari Newbie

      Guys, i'm writting an application using JBoss and JNDI to make the access and the pool to the database. But i'm with a serious problem, because Jboss isn't releasing the connections. This problem occours especifically in a Quartz Job, that runs to each X minutes, e.g., in the most times this job runs, it creates a process(connection) to access de DB, but it doesn't release this process, stay there forever. This Job is save in the DB, e.g., isn't configured by xml. How i'm doing:

      postgres-ds.xml

      ..
       <local-tx-datasource>
       <jndi-name>PostgresDS</jndi-name>
       <connection-url>jdbc:postgresql://localhost:5432/nomeBanco</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>usuario</user-name>
       <password>senha</password>
       <prepared-statement-cache-size>50</prepared-statement-cache-size>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>200</max-pool-size>
       <max-idle-timeout>0</max-idle-timeout>
       <blocking-timeout-millis>30000</blocking-timeout-millis>
       <idle-timeout-minutes>2</idle-timeout-minutes>
       <track-statements>true</track-statements>
       <!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL
       <new-connection-sql>select 1</new-connection-sql>
       -->
      
       <!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL
       <check-valid-connection-sql>select 1</check-valid-connection-sql>
       -->
      
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <!--metadata>
       <type-mapping>PostgreSQL 7.2</type-mapping>
       </metadata-->
       </local-tx-datasource>
      ..
      


      applicationContext.xml
      ..
       <bean id="dataSource"
       class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="java:PostgresDS" />
       </bean>
      
       <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
       <constructor-arg>
       <ref bean="dataSource" />
       </constructor-arg>
       </bean>
      
       <bean id="daoSpring" class="..DAOSpring">
       <property name="jdbcTemplate" ref="jdbcTemplate"/>
       </bean>
      
       <bean id="service" class="..Service">
       <property name="dao" ref="daoSpring"/>
       </bean>
      ..
      


      And then in the Job:

      ..
       ApplicationContext factory = new ClassPathXmlApplicationContext("/WEB-INF/applicationContext.xml");
       Service service = (Service)factory.getBean("service");
      ..
      


      I've already tried to change the datasource configuration, changed de kind from "local" to "xa", looked for a lot of things about it on net, but i'm not really been able to solve this problem. Does anyone has any idea about something that could help me?

      Thaks very much and sorry for the english.

        • 1. Re: Jboss connection pool doesn't release the connections
          jaikiran pai Master

          JBoss maintains a pool of connections. When an application requests for a connection from the datasource, the server returns a connection from this pool. The application then has to call the close method on the connection so that the connection is returned back to the pool (where it continues to stay). Is your application calling the close method on the connection, once it is done with whatever processing it does?