- #1
Darkstar3000
- 29
- 0
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
Example Code :
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:
ResultSet result = select.executeQuery("SELECT *, FROM Titles");
System.out.println("Got results: ");/
while(result.next()){
// what do I put here ?
}
Example Code :
Code:
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: