private <T> List<T> getColumnMetadata(ResultSet rs, ColumnMetadataAccessor<T> colAccessor)
      throws Exception {
    assert rs != null;
    ResultSetMetaData metadata = rs.getMetaData();
    int numColumns = metadata.getColumnCount();
    List<T> columnMeta = new ArrayList<>(numColumns);
    for (int i = 0; i < numColumns; i++) {
      columnMeta.add(colAccessor.get(metadata, i + 1));
    }
    return columnMeta;
  }
A data accessor that should in theory work with all JDBC compliant database drivers.
jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/GenericJdbcDatabaseAccessor.java