5.2
Write a Java method using JDBC metadata features that takes a ResultSet as an input parameter and prints out the result in tabular form, with appropriate names as column headings.
printTable(ResultSet result) throws SQLException {
= result.getMetaData();
metadata = metadata.getColumnCount();
num_cols for (int i = 1; i <= num_cols; i++) {
System.out.print(metadata.getColumnName(i) + '\t');
}
System.out.println();
while (result.next()) {
for (int i = 1; i <= num_cols; i++) {
System.out.print(result.getString(i) + '\t');
}
System.out.println();
}
}