Hi,

        I am also getting the same problem. I am using Jboss 3.2.3 and 
Postgresql 8.0 windows version.  I found that connections are not getting 
closed or they are returned to pool even though my code is seems to be right. 
Ultimately all connections are open and finally i need to restart the jboss. I 
am writing the code for getting connection like this:

import java.sql.Connection;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;


public class DBConnection{


        static javax.sql.DataSource DataSrc = null;
        static SQLQueryProperties sqlQueryObj = null;
        static int no_connections=0;

        static
        {
                try
                {
                        sqlQueryObj = SQLQueryProperties.getInstance();
                        DataSrc = 
(DataSource)sqlQueryObj.getContext().lookup(sqlQueryObj.getProperty("DataSourceJNDI"));
                }
                catch(Exception e)
                {
                        e.printStackTrace();
                }
        }

        public DBConnection() throws Exception
        {
        }

        public Connection getDBConnection() throws Exception
        {
                Connection cn=DataSrc.getConnection();
                no_connections++;
                return cn;
        }

        public Connection getConnection() throws Exception
        {
                Connection cn=DataSrc.getConnection();
                no_connections++;
                return cn;
        }
        public void returnDBConnection(Connection con) throws Exception 
        {
                if(!con.isClosed()) {con.close(); no_connections--;}
        }

        public void returnConnection(Connection con) throws Exception 
        {
                  System.out.println("NO OF CONNECTIONS OPENED IS 
:"+no_connections);
                                
                if(!con.isClosed()) {con.close(); no_connections--;}
                System.out.println("AFTER CLOSE NO OF CONNECTIONS REMAINED IS 
:"+no_connections);
        }

        public static int countConnections(){
                return no_connections;
        }

}

         There is some piece of code to count the no of connections open and 
closed. And my postgres-ds.xml is like this:


  <local-tx-datasource>
    <jndi-name>PostgresDS</jndi-name>
<connection-url>jdbc:postgresql://ipaddress:5432/database
</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
<transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation>
    <user-name>user</user-name>
        <min-pool-size>2</min-pool-size>
    <max-pool-size>10</max-pool-size>

<blocking-timeout-millis>20000</blocking-timeout-millis>
    <idle-timeout-minutes>0</idle-timeout-minutes> 
  </local-tx-datasource>



     I don't what to do to close the opened connections. Because of this i am 
facing a lot of problem in development environment. 

     Please let me know what should i do to get rid of this problem.


Thanks and Regards
Ram


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3873046#3873046

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3873046


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to