private void executeAddDatasetStatement(PreparedStatement statement, int accountId, int containerId, Dataset dataset)
      throws SQLException, AccountServiceException {
    String datasetName = dataset.getDatasetName();
    if (dataset.getVersionSchema() == null) {
      throw new AccountServiceException("Must set the version schema info during dataset creation",
          AccountServiceErrorCode.BadRequest);
    }
    int schemaVersionOrdinal = dataset.getVersionSchema().ordinal();
    String retentionPolicy = dataset.getRetentionPolicy();
    Integer retentionCount = dataset.getRetentionCount();
    Long retentionTimeInSeconds = dataset.getRetentionTimeInSeconds();
    Map<String, String> userTags = dataset.getUserTags();
    String userTagsInJson;
    try {
      userTagsInJson = objectMapper.writeValueAsString(userTags);
    } catch (IOException e) {
      throw new AccountServiceException("Fail to serialize user tags : " + userTags.toString(),
          AccountServiceErrorCode.BadRequest);
    }
    statement.setInt(1, accountId);
    statement.setInt(2, containerId);
    statement.setString(3, datasetName);
    statement.setInt(4, schemaVersionOrdinal);
    if (retentionPolicy != null) {
      statement.setString(5, retentionPolicy);
    } else {
      //set to the default
      statement.setString(5, DEFAULT_RETENTION_POLICY);
    }
    if (retentionCount != null) {
      statement.setInt(6, retentionCount);
    } else {
      statement.setObject(6, null);
    }
    if (retentionTimeInSeconds != null) {
      statement.setLong(7, retentionTimeInSeconds);
    } else {
      statement.setObject(7, null);
    }
    if (userTags != null) {
      statement.setString(8, userTagsInJson);
    } else {
      statement.setString(8, null);
    }
    statement.executeUpdate();
  }
Execute insertDatasetStatement to add Dataset.
@param statement the mysql statement to add dataset.
@param accountId the id for the parent account.
@param containerId the id of the container.
@param dataset the {@link Dataset}
@throws SQLException
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java