DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    39

    ResultSet is type forward only

    I am a new developer in JSP and Java. I am building a site using JSP and running an SQL statement the following

    String Search = "Select claimNo from claim;";
    Statement stmt1 =con.createStatement();

    ResultSet res = stmt1.executeQuery(Search);

    res.first();
    int r=0;

    while (res.next())
    {
    r = res.getInt("claimNo");

    }
    res.close();
    out.println(r);

    Result set type is TYPE_FORWARD_ONLY. From my research, I understand that a result set can be scrollable or Type_Forward_Only. I tried by initializing the result set to res.first(); before using the result set, but I am still getting the error message.
    If I use while (res.last()) I am still receiving the same message. I really want to loop through the result set to the last tuple in my database.

    Can anyone help resolve this problem?

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    After you do this:

    ResultSet res = stmt1.executeQuery(Search);

    you are positioned before the first record. Then you loop through like:
    Code:
    while (res.next()) {
      System.out.printlnt(res.getInt("claimNo"));
    }
    ... and thats basically it...
    eschew obfuscation

Similar Threads

  1. empty ResultSet...
    By customwoodtek in forum Java
    Replies: 1
    Last Post: 08-18-2005, 03:51 AM
  2. Replies: 3
    Last Post: 04-14-2001, 04:18 AM
  3. Get type info for Parent.Controls items
    By Michael Bourns in forum VB Classic
    Replies: 10
    Last Post: 12-08-2000, 02:22 AM
  4. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 10:24 PM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links