Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

embedded sql statements... "Reference Counting Error"

Posted on 2002-07-15
7
Medium Priority
?
292 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
  • 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
Industry Leaders: 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

885 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