pentaho/pentaho-kettle · error · RuntimeException

Setting a directory on a database connection is not…

Error message

Setting a directory on a database connection is not supported

What it means

DatabaseMeta implements RepositoryElementInterface; its setRepositoryDirectory override unconditionally throws RuntimeException because database connections always live at the repository root and cannot be placed in folders. Assigning a directory to a connection object is a programming error by contract.

Solutions

  1. Skip DatabaseMeta objects in generic code that sets repository directories (check getRepositoryElementType() == REPOSITORY_ELEMENT_TYPE).
  2. Use the explicit repository API (Repository.save(meta, version, comment, directory)) instead of setting a directory field on the meta.
  3. For moving connections in a repository, use repository-specific move/rename methods rather than setRepositoryDirectory.
  4. Wrap the call defensively if the element type is unknown at compile time.

Example fix

// before
repoElement.setRepositoryDirectory(targetDir); // applied to all element types
// after
if (repoElement.getRepositoryElementType() != RepositoryObjectType.DATABASE) {
  repoElement.setRepositoryDirectory(targetDir);
} else {
  repository.moveToRepositoryElement(...); // or leave connections at root
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (element instanceof DatabaseMeta) {
  // connections live at repository root; do not assign a directory
} else {
  element.setRepositoryDirectory(dir);
}

Type guard

boolean supportsDirectory(RepositoryElementInterface e) {
  return !(e instanceof DatabaseMeta);
}

Try / catch

try {
  element.setRepositoryDirectory(dir);
} catch (RuntimeException e) {
  if ("Setting a directory on a database connection is not supported".equals(e.getMessage())) {
    // handle connection case: save at root via repository API instead
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling meta.setRepositoryDirectory(dir) — typically from generic repository code that sets directories on every repository element type (jobs, transformations, connections) uniformly, hitting the connection case.

Common situations: Bulk repository import/export scripts that iterate repository objects and assign target directories; refactored repository browsers applying directory moves to DatabaseMeta objects.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/046b0e31b7196eb4. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/DatabaseMeta.java:2946

  public String getPreferredSchemaName() {
    return databaseInterface.getPreferredSchemaName();
  }

  public void setPreferredSchemaName( String preferredSchemaName ) {
    databaseInterface.setPreferredSchemaName( preferredSchemaName );
  }

  /**
   * Not used in this case, simply return root /
   */
  @Override
  public RepositoryDirectoryInterface getRepositoryDirectory() {
    return new RepositoryDirectory();
  }

  @Override
  public void setRepositoryDirectory( RepositoryDirectoryInterface repositoryDirectory ) {
    throw new RuntimeException( "Setting a directory on a database connection is not supported" );
  }

  @Override
  public RepositoryObjectType getRepositoryElementType() {
    return REPOSITORY_ELEMENT_TYPE;
  }

  @Override
  public ObjectRevision getObjectRevision() {
    return objectRevision;
  }

  @Override
  public void setObjectRevision( ObjectRevision objectRevision ) {
    this.objectRevision = objectRevision;
  }

  @Override

View on GitHub (pinned to f3058517a1)