Hi,

 In order to recreate the problem of number of open connections with our 
application, I created a test case with a simple application.  While running  
stress tests on this simple application I noticed that database connections are 
not getting closed even through the application invokes close() method on the 
connection obtained from the container.  When I run the test with 50 concurrent 
users, I can see at the database end that 48 connections being created. But 
these connection are not getting closed even after the test is over. These 
connections go away only if I restart the jboss.
Any help appreciated.  Application code is listed below

Thanks
-Shaji

The application is a simple struts application querying a table in oracle 9i 
database. Jboss 4.0.1 is running on Windows 2000

Application code that make database query is listed below 



  public List getAllCDES(String longName) throws Exception
  {
    Connection conn = null;
    Statement st =null;
    ResultSet rs = null;
    List list = new ArrayList();
      try
      {
        conn = 
SimpleDAOImpl.getConnectionFromContainer("java:comp/env/jdbc/CDEBrowserDS");
        //Statement st = conn.
        String sqlStmt = "SELECT * FROM data_elements_view "
                        +"WHERE long_name like '"+longName+"'";
  
        st = conn.createStatement();
        rs = st.executeQuery(sqlStmt);  
       
        while(rs.next())
        {
          DataElement de = new DataElement();
          de.setLongName(rs.getString("long_name"));
          de.setPublicId(rs.getString("cde_id"));
          list.add(de);
        }
        
      }

      catch (Exception e)
      {
        System.out.println("Exception while getting CDEs");
        throw e;
      }
      finally
      {
        if(st!=null)
         try
         {
           st.close();
         }
         catch (Exception ex)
         {
           System.out.println("Exception while Closing st");
         }
         if(rs!=null)
          try
          {
            rs.close();
          }
          catch (Exception exp)
          {
            System.out.println("Exception while Closing rs");
          }
         if(conn!=null)
          try
          {
            conn.close();
            System.out.println("Connection Closed");
          }
          catch (Exception ecexp)
          {
            System.out.println("Exception while Closing Connection");
          }                 
      }
    return list;
    
  }
  
  public static Connection getConnectionFromContainer(String dataSourceName)
                     throws NamingException,Exception {

     Connection conn = null;
       try {
         InitialContext ic = new InitialContext();
         DataSource ds = (DataSource)ic.lookup(dataSourceName);
         conn = ds.getConnection();
         
         System.out.println("Connected to the database successfully using 
datasource "+dataSourceName);
       }
       catch (NamingException ne) {
         System.out.println("Exception occurred in getConnectionFromContainer 
for DataSource name="+dataSourceName);
         throw new NamingException
                 ("Failed to lookup JDBC datasource. Check the datasource 
name");
       }
       catch (Exception e) {
         System.out.println("Exception occurred in getConnectionFromContainer");
         throw new Exception("Exception in getConnectionFromContainer() ");
       }
       return  conn;
   }  

Below is the oracle-ds.xml entry


        <local-tx-datasource>
                <jndi-name>jdbc/CDEBrowserDS</jndi-name>
                
<connection-url>jdbc:oracle:thin:@myhost:1521:dev</connection-url>
                <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                <user-name>user</user-name>
                mypassword
                
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
                <blocking-timeout-millis>0</blocking-timeout-millis>
                <idle-timeout-minutes>0</idle-timeout-minutes>
                <max-pool-size>100</max-pool-size>
                <min-pool-size>0</min-pool-size>
        </local-tx-datasource>




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

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


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to