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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:01:58+00:00 2026-06-06T23:01:58+00:00

I hope that you can correct me if my syntax is wrong. I could

  • 0

I hope that you can correct me if my syntax is wrong. I could check on Google only if the SELECT…WHERE clause is correct.

I want to retrieve the student_id for using it in another query, but seems that all I get from this is a “0”.

in java file:

rst = stmt.executeQuery("SELECT student_id FROM students WHERE name= 'to_delete'");
sid = rst.getInt("student_id");

to_delete is a String which this java file receives as a parameter to the method which must return student_id. It really contains the correct string(I checked it).

Table “students” contains the fileds: student_id, name, year. I need to have returned the student_id for the name “to_delete”.

I have no errors/exceptions, just that when I display the result, I see id: 0 no matter what name I type. Maybe rst.getString(“column_name”) is correct only for executeUpdate(…)?

Thank you in advance!

  • 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-06T23:02:01+00:00Added an answer on June 6, 2026 at 11:02 pm

    Call next() on the resultset before you try to get anything out of it. You iterate through the ResultSet by calling the next method every time you want to read a row. When next returns false you’re done.

    Here’s the API documentation for the next method:

    boolean next()
    throws SQLException

    Moves the cursor froward one row from its current position. A
    ResultSet cursor is initially positioned before the first row; the
    first call to the method next makes the first row the current row; the
    second call makes the second row the current row, and so on.

    When a call to the next method returns false, the cursor is positioned
    after the last row. Any invocation of a ResultSet method which
    requires a current row will result in a SQLException being thrown. If
    the result set type is TYPE_FORWARD_ONLY, it is vendor specified
    whether their JDBC driver implementation will return false or throw an
    SQLException on a subsequent call to next.

    If an input stream is open for the current row, a call to the method
    next will implicitly close it. A ResultSet object’s warning chain is
    cleared when a new row is read.

    Returns:
    true if the new current row is valid; false if there are no more rows Throws:
    SQLException – if a database access error occurs or this method is called on a closed result set

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

Sidebar

Related Questions

I hope that you can help me. When I want to execute those .bat
Hope that someone can share their experience with some of the latest emerging backbone.js
Is there any way (utilizing Reflection I hope) that I can make an instantiated
This is a very strange problem, and I just hope that I can clearly
I'm new here same as I'm new with assembly. I hope that you can
I hope I can explain this well enough so that you can understand the
I have a few questions that I hope clarity and facts can be fed
I am having a JQuery/ASP issue that I hope someone can help me with.
Happy New Year SO users! I have an issue that I hope someone can
I hope I can explain this right I have two input fields that require

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.