Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By JosAH

Thread: How do i println every reocrd in the database?

  1. #1
    SnoopyX is offline Member
    Join Date
    Mar 2011
    Location
    Singapore
    Posts
    9
    Rep Power
    0

    Default How do i println every reocrd in the database?

    Hello all

    How do i println every reocrd in the database?

    Currently i have 14 record and i wanna System.out.println(); all the 14 record instead of printing the 1st record out. Any idea?

    My SQl statement: SELECT id FROM class;

    if(rs.next())
    {
    ID = rs.getString("ID");
    System.out.println(ID);
    success = true;
    }


    Thank you very much! Please give me some idea on how to print out all the 14 record from the database instead of printing out the very 1st record.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default

    Make it a while-loop? i.e.

    Java Code:
    while (rs.next()) { // while more records to print ...
       ID= rs.getString("ID");
       System.out.println(ID);
       ...
    }
    kind regards,

    Jos
    SnoopyX likes this.
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    SnoopyX is offline Member
    Join Date
    Mar 2011
    Location
    Singapore
    Posts
    9
    Rep Power
    0

    Default

    Thank you very much! I spent 3hours on this research and gave up so i asked on forums HEHE thanks ALOT.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by SnoopyX View Post
    Thank you very much! I spent 3hours on this research and gave up so i asked on forums HEHE thanks ALOT.
    Next time, first read the API documentation (google can find the link for you). Also Sun's/Oracle's Java tutorials can give you the answers to a lot of your questions.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. System.out.println
    By JohnDoe in forum New To Java
    Replies: 1
    Last Post: 09-05-2010, 10:14 AM
  2. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 08:52 AM
  3. Need help with println
    By jhetfield18 in forum New To Java
    Replies: 8
    Last Post: 09-18-2009, 08:26 AM
  4. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-18-2008, 11:06 PM
  5. System.out.println
    By Sniper-X in forum Advanced Java
    Replies: 10
    Last Post: 05-05-2008, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •