ResultSetMetaData rsmd - null:
try {
rsmd = rs.getMetaData():
} catch (SQLException se) {
System.out.printlnC'We got an exception while getting the metadata:" +
"check the connection."):
se.printStackTrace();
System.exit(l):
}
String columnName = null.
columnType = null:
try {
columnName = rsmd.getColumnName(1):
columnType - rsmd.getColumnTypeName(l):
} catch (SQLException se) {
System.out.printlnC'We got an exception while getting the column name:" +
"check the connection."):
se.printStackTrace():
System.exit(l):
}
System.out.printC'The name of the first column is: '"):
System.out.print(columnName);
System.out.printlrK.....):
System.out.printC'The data type of the first column is: "):
System.out.println(columnType):
Класс ResultSetMetaData содержит много других полезных методов. Описания приведены в документации JDK API.