{"record":{"id":"800165f469a92d33","repo":"pentaho/pentaho-kettle","slug":"kettledatabaserepository-exception-errordeletingconnection","errorCode":null,"errorMessage":"KettleDatabaseRepository.Exception.ErrorDeletingConnection.Message","messagePattern":"KettleDatabaseRepository\\.Exception\\.ErrorDeletingConnection\\.Message","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDatabaseDelegate.java","lineNumber":353,"sourceCode":"\n  /**\n   * Remove a database connection from the repository\n   *\n   * @param databaseName\n   *          The name of the connection to remove\n   * @throws KettleException\n   *           In case something went wrong: database error, insufficient permissions, depending objects, etc.\n   */\n  public void deleteDatabaseMeta( String databaseName ) throws KettleException {\n\n    repository.getSecurityProvider().validateAction( RepositoryOperation.DELETE_DATABASE );\n\n    try {\n      ObjectId id_database = getDatabaseID( databaseName );\n      delDatabase( id_database );\n\n    } catch ( KettleException dbe ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"KettleDatabaseRepository.Exception.ErrorDeletingConnection.Message\", databaseName ), dbe );\n    }\n  }\n\n  public synchronized void delDatabase( ObjectId id_database ) throws KettleException {\n    repository.getSecurityProvider().validateAction( RepositoryOperation.DELETE_DATABASE );\n\n    // First, see if the database connection is still used by other connections...\n    // If so, generate an error!!\n    // We look in table R_STEP_DATABASE to see if there are any steps using this database.\n    //\n    String[] transList = repository.getTransformationsUsingDatabase( id_database );\n    String[] jobList = repository.getJobsUsingDatabase( id_database );\n\n    if ( jobList.length == 0 && transList.length == 0 ) {\n      repository.connectionDelegate.performDelete( \"DELETE FROM \"\n        + quoteTable( KettleDatabaseRepository.TABLE_R_DATABASE ) + \" WHERE \"\n        + quote( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE ) + \" = ? \", id_database );","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryDatabaseDelegate.java#L335-L371","documentation":"Wraps any KettleException from locating or deleting a database connection by name in deleteDatabaseMeta, using the localized message key KettleDatabaseRepository.Exception.ErrorDeletingConnection.Message with the connection name interpolated. Typical inner cause is the connection name not resolving to an id, or a failed delete statement.","triggerScenarios":"Calling deleteDatabaseMeta(databaseName) where getDatabaseID(databaseName) fails (no such connection) or delDatabase(id_database) throws a database error.","commonSituations":"Deleting a connection that was already removed or renamed; case-sensitivity mismatch in the name; permission denied by the security provider for DELETE_DATABASE; DB error during the delete.","solutions":["Confirm the exact connection name exists in the repository (Repository Explorer) including case","Check the connected user has permission to delete database connections (RepositoryOperation.DELETE_DATABASE)","Inspect the wrapped KettleException for the underlying database failure","If it's a dependency issue, see the related 'still in use by N jobs and M transformations' error and remove references first"],"exampleFix":"// before\nrepository.deleteDatabaseMeta(\"OldConn\"); // may not exist\n// after\nif (repository.getDatabaseIDs(false).stream().anyMatch(id ->\n    \"OldConn\".equals(repository.getDatabaseMeta(id).getName()))) {\n  repository.deleteDatabaseMeta(\"OldConn\");\n}","handlingStrategy":"validation","validationCode":"// verify the connection exists before deleting\nObjectId id = databaseDelegate.getDatabaseID(databaseName);\nif (id == null) { return; } // nothing to delete, skip","typeGuard":"ObjectId id = databaseDelegate.getDatabaseID(name);\nif (id == null) { throw new IllegalArgumentException(\"No such database connection: \" + name); }","tryCatchPattern":"try {\n  repository.deleteDatabaseMeta(name);\n} catch (KettleException e) {\n  if (e.getCause() instanceof KettleDependencyException) {\n    // handle in-use case (see dependency error)\n  } else { throw e; }\n}","preventionTips":["Look up connections by exact (case-sensitive) name before deleting","Grant DELETE_DATABASE permission only to admins","Check usage/references before any delete operation"],"tags":["database","repository","delete","resource-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}