/*
   * This method will:
   * 1. apply the modified DatabaseConfig to the database.
   * 2. close the database and do a sync to make sure the new configuration
   *    is written to the log.
   * 3. open the database with a useExisting config and return the current
   *    DatabaseConfig.
   */
  private DatabaseConfig setAndGetDbConfig(Environment env, DatabaseConfig dbConfig, String dbName)
      throws Exception {

    Database db = env.openDatabase(null, "foo", dbConfig);
    db.close();

    env.sync();

    /*
     * Open with the useExisting config to see what attributes have been
     * persisted.
     */
    DatabaseConfig newConfig = new DatabaseConfig();
    newConfig.setReadOnly(true);
    newConfig.setTransactional(true);
    newConfig.setUseExistingConfig(true);

    db = env.openDatabase(null, dbName, newConfig);
    newConfig = db.getConfig();
    db.close();

    return newConfig;
  }