[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JDBC and Oracle load testing

Posted on 2007-10-16
2
Medium Priority
?
334 Views
Last Modified: 2013-12-19
Hi All,

We are doing load testing for our jsp application running in Resin and Oracle 9i. The load testing tool that we are using is JBlitz.  When we set the concurrent user to 1, our application can run smoothly i.e. the number of cursors remain as 1. But, once we set the concurrrent user to 2, the number of cursors keeps on rising.

Here's snippet of the codes

sqlMethod class
                     public static synchronized ResultSet rsQuery(String sql)
        {
              try
              {
                    con=ConnectionBean.getConnection();
                    st=con.createStatement();
                    rs=st.executeQuery(sql);
       
                }
              catch(Exception e)
              {
                     System.out.println("sqlMethod rsQuery is abnormal"+e);
              }
              finally
              {
                    close();
              }
              return rs;
        }

                      public static  synchronized void close()
        {
              try
              {
                    if (con != null) {
                          ConnectionBean.close();
                    }
              }
              catch(Exception er)
              {
                    System.out.println("con='" + con + "' close is abnormal "+er);
              }

        }

                    public static  synchronized void closeStmt()
        {
              try
              {
                    //System.out.println("Statement='" + st + "'");
                    if (st != null) {
                           st.close();
                           st = null;
                    }
              }
              catch(Exception er)
              {
                    System.out.println("st='" + st + "' close is abnormal "+er);
              }

        }




ConnectionBean class:
 public static synchronized void close() throws Exception
  {
    if (con != null)
    {
             con.close();
             con = null;
             System.out.println("Connection.close() = '"+con+"'");
        }
  }


Example of methods that uses the connection:
Vector v = new Vector();
         
       String querySql = "SELECT * FROM QType ORDER BY SEQUENCE";      
       
        try
        {          
            ResultSet rs=sqlMethod.rsQuery(querySql);      
                       
            while(rs.next())
            {
                  voQType vo = new voQType();
                  vo.setPKQType(rs.getInt("PKQType"));
                  vo.setQType(rs.getString("QType"));
                 
                  v.add(vo);
            }
           rs.close();
           rs = null;
        }
        catch(Exception E)
        {
           
            System.err.println("Q.java - getQTypes - " + E);
        }
        finally
        {
              sqlMethod.close();
              sqlMethod.closeStmt();
        }
        return v;



Any suggestions on how to improve the codes?

Thank you.
0
Comment
Question by:rospcc
2 Comments
 
LVL 12

Assisted Solution

by:Gibu George
Gibu George earned 200 total points
ID: 20084364
Hello rospcc,

How are you obtaining the connection object? Are you using any Connectio Pooling? Also make sure that you are closing the connections after the use.

Regards,

gibu_george
0
 
LVL 35

Accepted Solution

by:
TimYates earned 1800 total points
ID: 20084387
Try closing things in the reverse order they are created:

ie:

    finally
    {
        try { if( rs != null ) rs.close() ; } catch( SQLException ex ) { ex.printStackTrace() ; }
        try { if( stmt != null ) stmt.close() ; } catch( SQLException ex ) { ex.printStackTrace() ; }
        try { if( conn != null ) conn.close() ; } catch( SQLException ex ) { ex.printStackTrace() ; }
    }

Resultset first, then Statement, then Connection

Although ResultSet is *usually* closed by closing the statement, I never trust it, so tend to do it myself anyway...

Tim
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question