code: public static String fromResultSet(ResultSet resultSet) throws SQLException {
      if (resultSet == null) throw new NullPointerException("resultSet == null");
      if (!resultSet.isBeforeFirst()) throw new IllegalStateException("Result set not at first.");
  
      List<String> headers = new ArrayList<>();
      ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
      int columnCount = resultSetMetaData.getColumnCount();
      for (int column = 0; column < columnCount; column++) {
        headers.add(resultSetMetaData.getColumnName(column + 1));
      }
  
      List<String[]> data = new ArrayList<>();
      while (resultSet.next()) {
        String[] rowData = new String[columnCount];
        for (int column = 0; column < columnCount; column++) {
          rowData[column] = resultSet.getString(column + 1);
        }
        data.add(rowData);
      }
  
      String[] headerArray = headers.toArray(new String[headers.size()]);
      String[][] dataArray = data.toArray(new String[data.size()][]);
      return FlipTable.of(headerArray, dataArray);
    }
docs: Create a table from a {@link ResultSet}.