Solved

embedded sql statements... "Reference Counting Error"

Posted on 2002-07-15
7
282 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 250 total points
Comment Utility
 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
Comment Utility
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
Comment Utility
jsp.. Websphere 3.54
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 35

Expert Comment

by:girionis
Comment Utility
 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
Comment Utility
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
Comment Utility
jsp.. Websphere 3.54
0
 

Author Comment

by:brian_s
Comment Utility
jsp.. Websphere 3.54
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java virtual machine monitoring tools 3 39
countHi challenge 25 84
array6 challenfge 6 62
Books that can get me started on JAVA 2 52
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…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now