1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Qustion about JDBC

  1. May 15, 2012 #1
    Question about JDBC

    Here is a snippet of some JDBC code I wrote, I want to know what I have to put in the while block to iterate the result, I've seen examples of JDBC code but have no idea how you choose what to put in the while block and how it helps with the final result, can anyone explain this to me ?

    My code
    Code (Text):


    ResultSet result = select.executeQuery("SELECT *, FROM Titles");

                System.out.println("Got results: ");/
               
               
                while(result.next()){

                   // what do I put here ?
                    }
     
    Example Code :

    Code (Text):

    Statement statement = connection.createStatement();

    String sql = "select * from people";

    ResultSet result = statement.executeQuery(sql);

    while(result.next()) {

        String name = result.getString("name");
        long   age  = result.getLong("age");

        System.out.println(name);
        System.out.println(age);
    }

    result.close();
    statement.close();

     
     
    Last edited: May 16, 2012
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Qustion about JDBC
Loading...