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
    13,776
    Blog Entries
    7
    Rep Power
    21

    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.
    cenosillicaphobia: the fear for an empty beer glass

  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
    13,776
    Blog Entries
    7
    Rep Power
    21

    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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. System.out.println
    By JohnDoe in forum New To Java
    Replies: 1
    Last Post: 09-05-2010, 11:14 AM
  2. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 09:52 AM
  3. Need help with println
    By jhetfield18 in forum New To Java
    Replies: 8
    Last Post: 09-18-2009, 09:26 AM
  4. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-19-2008, 12:06 AM
  5. System.out.println
    By Sniper-X in forum Advanced Java
    Replies: 10
    Last Post: 05-05-2008, 04: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
  •