Reputation: 11
I am using Eclipse SDK 3.2.0, and I am connecting to Oracle 11g using Java. I am using a simple JDBC connection. I am assigning my queried data to the Result set function. I am able to get one column at a time using rs.getstring. How can I get all the columns printed one a time within my 'while' loop using rs.next()?
Upvotes: 0
Views: 109
Reputation: 2051
What about:
while(rs.next()) {
for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
System.out.println("col-nr: %d - %s", i, rs.getString(i));
}
}
Upvotes: 3
Reputation: 174
I guess you want get all columns data. you can try ResultSetMetaData class.
ResultSet rs = xxx;
ResultSetMetaData rsmd =rs.getMetadata();
Upvotes: 0