Solved

embedded sql statements... "Reference Counting Error"

Posted on 2002-07-15
7
287 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

623 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