Solved

embedded sql statements... "Reference Counting Error"

Posted on 2002-07-15
7
286 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 250 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web application structure 18 117
null output 3 43
add projects t working set in maven 2 44
import as existing maven project 3 42
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

730 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