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 8676247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:08:46+00:00 2026-06-12T20:08:46+00:00

I am coding a simple CRUD Application in java and I have a Method

  • 0

I am coding a simple CRUD Application in java and I have a Method to select Produkts that go with bills.

Here is my code:

public Rechnung selectProdukte(int target){
    int tempProdukt;
    int tempAnzahl;
    try {
        PreparedStatement ps1=hsqlmanager.getConnection().prepareStatement("SELECT produkt, anzahl from gekauftes_produkt " +
                "WHERE rechnung= " + target + ";");
        //ps1.setInt(1, target);
        //Query 1wird executiert

        PreparedStatement ps2 = hsqlmanager.getConnection().prepareStatement("SELECT * FROM rechnung WHERE id= " + target + ";");
        //ps2.setInt(1, target);
        ResultSet rs1 = ps1.executeQuery();
        ResultSet rs2 = ps2.executeQuery();
        Rechnung erg=new Rechnung(); 
        erg.setId(rs2.getInt(1));
        erg.setDatum(rs2.getDate(2));
        erg.setSumme(rs2.getDouble(3));
        while(rs1.next()){
            tempProdukt=rs1.getInt(1);
            tempAnzahl=rs1.getInt(2);
            erg.addGekauftTupel(tempProdukt, tempAnzahl);
        }
        ps1.close();
        ps2.close();
        return erg;
    } catch(Exception e) {
        log.error("Fehler in DAO Rechnung  - selectProdukte: " + e);
    }
    return null;
}

When I press the Button to execute the code I get:

java.sql.SQLException: invalid cursor state: identifier cursor not
positioned on row in UPDATE, DELETE, SET, or GET statement: ;
ResultSet is positioned before first row

I checked the db and all the tables and entities exist. So my question is:

What does that mean?

I appreciate your answer!!!

PS.: I am using hsql db!

  • 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-12T20:08:47+00:00Added an answer on June 12, 2026 at 8:08 pm

    you have not called rs2.next() before accessing erg.setId(rs2.getInt(1));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coding a simple local search algorithms for TSP in java. Here's the method:
I'm coding a simple graphics program in Java. So, I have 3 classes. The
I'm coding a simple little class with a single method send an email. My
I'm coding a simple android application which contains a list, populated with a SimpleCursorAdapter.
I have a simple form that passes to an ASPX page to watch a
I'm currently coding a simple search script in PHP that requires three variables from
I had a frustrating problem recently that boiled down to a very simple coding
Basic question here, just got curious about coding a simple formula out, and wanted
I have this simple piece of coding in my Homecontroller.cs, but I receive the
I'm coding a simple roguelike game in C++ using SDL library, and I have

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.