Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:58:19+00:00 2026-06-01T22:58:19+00:00

m trying to loop through 3 resultsets and compare their values. bt its throwing

  • 0

m trying to loop through 3 resultsets and compare their values. bt its throwing this exception…could someone help me on where am going through?
here is the piece of code:

java.lang.Object[] reconciledPaymentDetails = null;

java.util.Vector shiftsVector = new java.util.Vector(1, 1);

String status = "";

try {

    Class.forName("org.postgresql.Driver");
    } 
catch (ClassNotFoundException ex) {
    Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
   }
try {
    connDB = DriverManager.getConnection("jdbc:postgresql://" + hostName + ":" + portNumber + "/" + dbName, userName, password);

    System.out.println("Connection established : [" + connDB.toString() + "]");

    java.sql.Statement pstmt = connDB.createStatement();

    java.sql.Statement pstmtShifts = connDB.createStatement();

    java.sql.ResultSet rset = pstmt.executeQuery("SELECT DISTINCT payment_mode,transaction_type, credit FROM ac_cash_collection WHERE shift_no = '" + shiftNumber + "'");

    while (rset.next()) {

        java.sql.ResultSet rsetShifts = pstmtShifts.executeQuery("SELECT DISTINCT amount, shift_amount FROM ac_shift_collections WHERE shift_no = '" + shiftNumber + "' AND pay_mode ilike '"+rset.getString(1) +"'");

        while (rsetShifts.next()) {

            java.sql.ResultSet rset2 = pstmt.executeQuery("select debit from ac_cash_book where shift_no='"+shiftNumber+"'");


           while (rset2.next()){

                double debit =rset2.getDouble("debit");

                if((rset2.getDouble("debit")<=0 ))

             status = "no_banked";

               else if((rset2.getDouble("debit")==rsetShifts.getDouble("amount"))
                        && (rsetShifts.getDouble("amount"))< rsetShifts.getDouble("shift_amount"))
                        status= "BntClosed";
                else if (rset2.getDouble(1)==rsetShifts.getDouble("shift_amount"))
                    status ="bClosed";




            shiftsVector.addElement(rset.getString(1)+":"+rsetShifts.getString(1)+":"+status);

            } 
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:58:20+00:00Added an answer on June 1, 2026 at 10:58 pm

    The documentation provides a clear explanation of this:

    By default, only one ResultSet object per Statement object can be open
    at the same time. Therefore, if the reading of one ResultSet object is
    interleaved with the reading of another, each must have been generated
    by different Statement objects. All execution methods in the Statement
    interface implicitly close a statment’s current ResultSet object if an
    open one exists.

    So your options would be:

    1. Use a different Statement instance for each query.
    2. Collect all the results from each ResultSet (i.e. into a Set or a List) before moving on to the next one, and then run the comparison on the collected results instead of directly on the result-sets.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to loop through all possible values of a float like this:
I am trying to loop through this external JSON file(locally stored), but I cannot
Im trying to loop through a json files' object array to access its variables'
I'm trying to loop through an associative array with the help of the functions
I am trying to loop through a range and write values into the cells
I am trying to loop through a query string and pull out certain values
I'm stuck trying to loop through this array of GPS coordinates that puts pins
I'm trying to loop through the results of an httpservice, it is xml. This
I am trying to loop through a list and get an output like this:
I'm trying to loop through an array backwards, so I figured I could try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.