code: public static List<String> getFieldNames(ResultSetMetaData  resultSetMetaData) throws SQLException {
          List<String> columnNames = new ArrayList<>();
          int cols = resultSetMetaData.getColumnCount();
          for (int i = 1; i <= cols; i++) {
              columnNames.add(resultSetMetaData.getColumnName(i));
          }
          return columnNames;
      }
docs: Fetch the name of columns
  @param resultSetMetaData Active result set meta data.
  @return An array with all column names
  @throws SQLException