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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:05:09+00:00 2026-05-24T05:05:09+00:00

I am using a ResultSet to retrieve data from my SQL server. The code

  • 0

I am using a ResultSet to retrieve data from my SQL server. The code looks as follows:

ResultSet rs = getValueFormTable();

I’m looping over the ResultSet like this:

do{
   // process data
} while(rs.next());

Suppose there are 10 records and I am at the fourth value of the ResultSet. There comes the situation that I need take one value of the fifth ResultSet record again return back to the fourth Resultset record.

Is that possible?

  • 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-05-24T05:05:09+00:00Added an answer on May 24, 2026 at 5:05 am

    Suppose there are 10 records and i am in fourth ResultSet Value. There comes the situation that i need to need take one value of the fifth ResultSet again return back to the fourth Resultset. Is that possible in java?

    You need “scrollable” ResulSet instances to achieve to scroll through the resultset; if you need to update the previous resultsets then you need scrollable and updatable resultsets (the last paragraph discusses updatable resultsets). Typically, ResultSets are TYPE_FORWARD_ONLY and can be scrolled only in the forward direction using the next() method.

    You will need to create a ResultSet instance of type TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE to invoke other methods like absolute() and previous() for moving back and forth the ResultSet.

    Creating a scrollable ResultSet requires you to specify the type of ResultSet returned by the Statement or PreparedStatement object, as the default type is TYPE_FORWARD_ONLY as stated earlier. A snippet demonstrating how to do so is shown below:

    PreparedStatement pStmt = Connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = pStmt.executeQuery();
    ...
    // You can now invoke rs.previous(), rs.absolute(n) etc. to move back and forth.
    

    You would want to read up on how to specific the type of the ResultSet in the Connection.createStatement, Connection.prepareStatement and Connection.prepareCall methods.

    If you want to modify the contents of the ResultSet and not just read from it, then you will need to create “updatable” ResultSets. This is easily done, by specifying the ResultSet concurrency type as CONCUR_UPDATABLE. You can then invoke any of the updateXXX methods and follow them with an updateRow method to update the underlying datasource.

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

Sidebar

Related Questions

I'm using an AutoCompleteExtender in ASP.NET/C# to retrieve data from my database, along with
I am trying to retrieve some data from a database using jQuery's $.getJSON method
I'm using Hibernate to retrieve some data from a database. The result set returned
I'm using IMDbPY to retrieve data from IMDb. I'm getting the right results and
Using DBIx::Class and I have a resultset which needs to be filtered by data
When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while
I'm using ColdFusion to return a result set from a SQL database and turn
I am using SQL Server 2008 Enterprise on Windows Server 2008 Enterprise. I am
I need to retrieve data from several rows and then insert the results into
I have an Excel spreadsheet that needs to display data from our SQL database.

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.