Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

embedded sql statements... "Reference Counting Error"

Posted on 2002-07-15
7
Medium Priority
?
289 Views
Last Modified: 2010-03-31
Can somebody please help....
here's is my code which fails due to--> Reference Counting Error.
-------------------------------------------
public void loadSalesForecast(String allSelectedReps, String pSalesOpt){
      BuildSelectedOptions(pSalesOpt, allSelectedReps);
      this.SalesForecast = new Vector(1);

      this.sql = "select distinct(companyid) "+
                 "from tblQuoteMaster "+
                 "where quotenumber in (select quotenumber from tblOrderMaster where ordernumber in (select ordernumber from tblOrderInvoice))";
      try{
         this.con = Conn.getPooledConnection();
         this.stmt = this.con.createStatement();
         this.rs = this.stmt.executeQuery(this.sql);
         while(this.rs.next()){
            this.sql2 = "select to_char(min(invoice_date),'Mon') "+
                          "from tblorderinvoice "+
                          "where ordernumber in (select ordernumber from tblordermaster where quotenumber in(select quotenumber from tblquotemaster where companyid = " + this.rs.getInt(1) + "))";
            try{
               this.con2 = Conn.getPooledConnection();
               this.stmt2 = this.con2.createStatement();
               this.rs2 = this.stmt2.executeQuery(this.sql2);
               this.rs2.next();
               this.tmp = this.rs2.getString(1) != null ? this.rs2.getString(1) : "NoDate";
               if(!this.tmp.equals("NoDate")){
                       this.sql3 =   "SELECT a.ordernumber, a.ORDER_DATE, a.order_bill_company, a.ORDER_SHIP_DATE, a.ORDER_SUBTOTAL, "+
                                       "billingreport.getamount(a.ordernumber) as order_total_due, a.ORDER_PO_NUMBER, a.staff_contact, "+
                                       "concat(concat(concat(c.calccompletiondate, ' ('), c.whichdate), ')') as ship_date, "+
                                       "i.invoice_amount, c.whichdate "+
                                       "FROM   tblactiveorder a, tblordermaster o, tblcompletiondate c, tblorderinvoice i "+
                                      "WHERE c.whichdate = 'I' "+
                                      "AND ((c.calccompletiondate >= '" + this.FromDate + "') and (c.calccompletiondate <= '" + this.ToDate + "')) "+
                                 "AND '"+this.tmp+"' = to_char(c.calccompletiondate,'Mon') "+
                                      "AND   a.ordernumber = o.ordernumber "+
                                      "AND   o.ordernumber = c.ordernumber "+
                                      "AND   a.ordernumber = i.ordernumber(+) "+
                                      "AND a.ordernumber not in (select ordernumber from tblordercancel where cancel_date is not null) "+
                                      "AND (      "+
                                      "       ('" + pSalesOpt + "' = 'ALL') or "+
                                      "       ( "+
                                        "          ('" + pSalesOpt + "' = 'SALESREP') and "+
                                        "          (ltrim(rtrim(upper(a.STAFF_CONTACT))) in (select upper(fname || ' ' || lname) from tblstaff where staff_key in("+ allSelectedReps +"))) "+
                                      "       ) "+
                                      "    ) "+
                                      "AND a.order_bill_company = (select company from tblcompany where companyid = " + this.rs.getInt(1) + ") "+
                                      "ORDER BY a.staff_contact, c.calccompletiondate";
                        try{
                           this.con3 = Conn.getPooledConnection();
                           this.stmt3 = this.con3.createStatement();
                           this.rs3 = this.stmt3.executeQuery(this.sql3);
                           while(this.rs3.next()){
                              this.SalesForecast.addElement(new Report(this.rs3.getInt(1), this.rs3.getDate(2), this.rs3.getString(3),
                                                      this.rs3.getDate(4), this.rs3.getBigDecimal(5), this.rs3.getBigDecimal(10),
                                                      this.rs3.getString(7), this.rs3.getString(8), this.rs3.getString(9)));
                           }
                        }
                        catch(SQLException e3){
                           System.err.println("_NewCustomerRpt.loadSalesForecast inner inner");
                           e3.printStackTrace();
                           System.err.println("SQL3--->"+this.sql3);
                        }
                        finally{
                           Close3();
                        }
               }
            }
            catch(SQLException e2){
               System.err.println("_NewCustomerRpt.loadSalesForecast inner");
               e2.printStackTrace();
            }
            finally{
               Close2();
            }
         }
      }
      catch(SQLException e){
         System.err.println("_NewCustomerRpt.loadSalesForecast outer");
         e.printStackTrace();
      }
      finally{
         Close();
      }

   }

   public void Close(){
      try{
            this.rs.close();
            this.stmt.close();
            this.con.close();
      }
      catch(SQLException e){
            this.rs = null;
            this.stmt = null;
            this.con = null;
      }
      finally{
            Conn.returnConnection();
      }
   }

   public void Close2(){
      try{
            this.rs2.close();
            this.stmt2.close();
            this.con2.close();
      }
      catch(SQLException e){
            this.rs2 = null;
            this.stmt2 = null;
            this.con2 = null;
      }
      finally{
            Conn.returnConnection();
      }
   }

   public void Close3(){
      try{
            this.rs3.close();
            this.stmt3.close();
            this.con3.close();
      }
      catch(SQLException e){
            this.rs3 = null;
            this.stmt3 = null;
            this.con3 = null;
      }
      finally{
            Conn.returnConnection();
      }
   }

0
Comment
Question by:brian_s
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 1000 total points
ID: 7154932
 Is it a command prompt application or a web based (Servlets/JSP)? If the latter, what server are you using? If you are using WebSphere there are some known problems with it.
0
 

Author Comment

by:brian_s
ID: 7154938
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
ID: 7154961
jsp.. Websphere 3.54
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 35

Expert Comment

by:girionis
ID: 7154970
 Maybe you should speak to the WebSphere guys about it. I think there is nothing wrong with your code.
0
 

Author Comment

by:brian_s
ID: 7154980
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
ID: 7154991
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
ID: 7155001
jsp.. Websphere 3.54
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

715 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