private Dataset executeGetDatasetStatement(PreparedStatement statement, int accountId, int containerId,
      String accountName, String containerName, String datasetName) throws SQLException, AccountServiceException {
    Dataset.VersionSchema versionSchema;
    String retentionPolicy;
    Integer retentionCount;
    Long retentionTimeInSeconds;
    Timestamp deletionTime;
    Map<String, String> userTags = null;
    ResultSet resultSet = null;
    try {
      statement.setInt(1, accountId);
      statement.setInt(2, containerId);
      statement.setString(3, datasetName);
      resultSet = statement.executeQuery();
      if (!resultSet.next()) {
        throw new AccountServiceException(
            "Dataset not found for account: " + accountId + " container: " + containerId + " dataset: " + datasetName,
            AccountServiceErrorCode.NotFound);
      }
      deletionTime = resultSet.getTimestamp(DELETED_TS);
      long currentTime = System.currentTimeMillis();
      if (compareTimestamp(deletionTime, currentTime) <= 0) {
        throw new AccountServiceException(
            "Dataset expired for account: " + accountId + " container: " + containerId + " dataset: " + datasetName,
            AccountServiceErrorCode.Deleted);
      }
      versionSchema = Dataset.VersionSchema.values()[resultSet.getInt(VERSION_SCHEMA)];
      retentionPolicy = resultSet.getObject(RETENTION_POLICY, String.class);
      retentionCount = resultSet.getObject(RETENTION_COUNT, Integer.class);
      retentionTimeInSeconds = resultSet.getObject(RETENTION_TIME_IN_SECONDS, Long.class);
      String userTagsInJson = resultSet.getString(USER_TAGS);
      if (userTagsInJson != null) {
        try {
          userTags = objectMapper.readValue(userTagsInJson, Map.class);
        } catch (IOException e) {
          throw new AccountServiceException("Fail to deserialize user tags : " + userTagsInJson,
              AccountServiceErrorCode.BadRequest);
        }
      }
    } finally {
      //If result set is not created in a try-with-resources block, it needs to be closed in a finally block.
      closeQuietly(resultSet);
    }
    return new Dataset(accountName, containerName, datasetName, versionSchema, retentionPolicy, retentionCount,
        retentionTimeInSeconds, userTags);
  }
Execute getDatasetStatement to get Dataset.
@param statement the mysql statement to get dataset.
@param accountId the id for the parent account.
@param containerId the id of the container.
@param accountName the name for the parent account.
@param containerName the name for the container.
@param datasetName the name of the dataset.
@return the {@link Dataset}
@throws SQLException
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java