pentaho/pentaho-kettle · error · KettleException

Error loading database connection from repository

Error message

Error loading database connection from repository (id_database={id_database})

What it means

Wraps a KettleDatabaseException raised while reconstructing a DatabaseMeta object from the R_DATABASE and R_DATABASE_ATTRIBUTE tables for a given id_database. The message names the offending id so the broken row can be located. Cause is the underlying database exception.

Solutions

  1. Verify a row with that id exists in R_DATABASE (query by id_database from the message)
  2. Check R_DATABASE_ATTRIBUTE rows for the id and re-enter the connection in Repository Explorer if corrupt
  3. Re-import or recreate the database connection and update the referencing object
  4. Inspect the cause KettleDatabaseException for the SQL-level failure

Example fix

// before: trust the stored id
DatabaseMeta db = databaseDelegate.loadDatabaseMeta(staleId);
// after: resolve id by name and handle absence
ObjectId id = databaseDelegate.getDatabaseID("MyConnection");
if (id != null) {
  DatabaseMeta db = databaseDelegate.loadDatabaseMeta(id);
}
Defensive patterns

Strategy: validation

Validate before calling

// confirm the connection id exists before loading
PreparedStatement ps = conn.prepareStatement("SELECT COUNT(*) FROM R_DATABASE WHERE ID_DATABASE = ?");
ps.setInt(1, idDatabase);
if (rsCount(ps) == 0) { throw new IllegalStateException("Database connection id " + idDatabase + " not in repository"); }

Type guard

ObjectId id = databaseDelegate.getDatabaseID(name);
if (id == null) { return null; } // or throw a clear not-found error

Try / catch

try {
  DatabaseMeta meta = delegate.loadDatabaseMeta(id);
} catch (KettleException e) {
  log.error("Load failed for id_database=" + id, e.getCause());
}

Prevention

When it happens

Trigger: Calling loadDatabaseMeta(id_database) when reading the R_DATABASE row or its attributes throws: missing/corrupt row, SQL error, or a bad attribute value preventing DatabaseMeta construction.

Common situations: Referencing a database connection id that no longer exists (stale id from another environment); corrupted R_DATABASE rows after a failed import; attribute rows lost after a partial delete/re-insert cycle.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDatabaseDelegate.java:146

        databaseMeta.setUsername( r.getString( KettleDatabaseRepository.FIELD_DATABASE_USERNAME, "" ) );
        databaseMeta.setPassword( Encr.decryptPasswordOptionallyEncrypted( r.getString(
          KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, "" ) ) );
        databaseMeta.setServername( r.getString( KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, "" ) );
        databaseMeta.setDataTablespace( r.getString( KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, "" ) );
        databaseMeta.setIndexTablespace( r.getString( KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, "" ) );

        // Also, load all the properties we can find...
        final Collection<RowMetaAndData> attrs = repository.connectionDelegate.getDatabaseAttributes( id_database );
        for ( RowMetaAndData row : attrs ) {
          String code = row.getString( KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, "" );
          String attribute = row.getString( KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, "" );
          databaseMeta.getAttributes().put( code, Const.NVL( attribute, "" ) );
        }
      }

      return databaseMeta;
    } catch ( KettleDatabaseException dbe ) {
      throw new KettleException( "Error loading database connection from repository (id_database="
        + id_database + ")", dbe );
    }
  }

  /**
   * Saves the database information into a given repository.
   *
   * @param databaseMeta
   *          The database metadata object to store
   *
   * @throws KettleException
   *           if an error occurs.
   */
  public void saveDatabaseMeta( DatabaseMeta databaseMeta ) throws KettleException {
    try {
      // If we don't have an ID, we don't know which entry in the database we need to update.
      // See if a database with the same name is already available...
      if ( databaseMeta.getObjectId() == null ) {

View on GitHub (pinned to f3058517a1)