private Page<String> executeListAllValidDatasetVersionsStatement(PreparedStatement statement, int accountId,
      int containerId, String datasetName, String pageToken, Dataset.VersionSchema versionSchema) throws SQLException {
    ResultSet resultSet = null;
    try {
      long pageTokenValue = pageToken == null? 0 : getVersionBasedOnSchema(pageToken, versionSchema);
      statement.setInt(1, accountId);
      statement.setInt(2, containerId);
      statement.setString(3, datasetName);
      statement.setInt(4, DatasetVersionState.READY.ordinal());
      statement.setLong(5, pageTokenValue);
      statement.setInt(6, mySqlAccountServiceConfig.listDatasetVersionsMaxResult + 1);
      resultSet = statement.executeQuery();
      List<String> entries = new ArrayList<>();
      String nextContinuationToken = null;
      int resultIndex = 0;
      while (resultSet.next()) {
        long versionValue = resultSet.getLong(VERSION);
        String version = convertVersionValueToVersion(versionValue, versionSchema);
        if (resultIndex == mySqlAccountServiceConfig.listDatasetVersionsMaxResult) {
          nextContinuationToken = version;
          break;
        }
        resultIndex++;
        entries.add(version);
      }
      return new Page<>(entries, nextContinuationToken);
    } finally {
      closeQuietly(resultSet);
    }
  }
Execute listValidDatasetVersionsSql statement.
@param statement the listValidDatasetVersionsSql statement.
@param accountId the id for the parent account.
@param containerId the id of the container.
@param datasetName the name of the dataset.
@param pageToken the page token.
@param versionSchema the dataset version schema.
@return the page of the dataset versions.
@throws SQLException
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java