{"record":{"id":"4b8518c5a2f2dfe4","repo":"pentaho/pentaho-kettle","slug":"unable-to-load-job-entry-of-type-sql-from-the-repository","errorCode":null,"errorMessage":"Unable to load job entry of type 'sql' from the repository with idJobentry=","messagePattern":"Unable to load job entry of type 'sql' from the repository with idJobentry=","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java","lineNumber":165,"sourceCode":"      if ( sSubs != null && sSubs.equalsIgnoreCase( \"T\" ) ) {\n        useVariableSubstitution = true;\n      }\n\n      String ssql = rep.getJobEntryAttributeString( idJobentry, SQLFROMFILE_TAG );\n      if ( ssql != null && ssql.equalsIgnoreCase( \"T\" ) ) {\n        sqlFromFile = true;\n      }\n\n      String ssendOneStatement = rep.getJobEntryAttributeString( idJobentry, SEND_ONE_STATEMENT_TAG );\n      if ( ssendOneStatement != null && ssendOneStatement.equalsIgnoreCase( \"T\" ) ) {\n        sendOneStatement = true;\n      }\n\n      sqlFilename = rep.getJobEntryAttributeString( idJobentry, SQLFILENAME_TAG );\n\n      databaseMeta = rep.loadDatabaseMetaFromJobEntryAttribute( idJobentry, CONNECTION_TAG, ID_DATABASE, databases );\n    } catch ( KettleDatabaseException dbe ) {\n      throw new KettleException( \"Unable to load job entry of type 'sql' from the repository with idJobentry=\"\n        + idJobentry, dbe );\n    }\n  }\n\n  // Save the attributes of this job entry\n  //\n  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId idJob ) throws KettleException {\n    try {\n      rep.saveDatabaseMetaJobEntryAttribute( idJob, getObjectId(), CONNECTION_TAG, ID_DATABASE, databaseMeta );\n\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQL_TAG, sql );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), USE_VARIABLE_SUBSTITUTION_TAG, useVariableSubstitution\n        ? \"T\" : \"F\" );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFROMFILE_TAG, sqlFromFile ? \"T\" : \"F\" );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFILENAME_TAG, sqlFilename );\n      rep.saveJobEntryAttribute( idJob, getObjectId(), SEND_ONE_STATEMENT_TAG, sendOneStatement ? \"T\" : \"F\" );\n    } catch ( KettleDatabaseException dbe ) {\n      throw new KettleException(","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java#L147-L183","documentation":"KettleException thrown by JobEntrySQL.loadRep when loading a 'sql' job entry's attributes (SQL from file flag, SQL filename, database connection) from the repository fails with a KettleDatabaseException, including failure of loadDatabaseMetaFromJobEntryAttribute to resolve the connection.","triggerScenarios":"Calling loadRep for a 'sql' job entry when getJobEntryAttributeString or loadDatabaseMetaFromJobEntryAttribute raises KettleDatabaseException: repository connection failure, missing R_JOBENTRY_ATTRIBUTE rows, or referenced database metadata (ID_DATABASE) cannot be loaded.","commonSituations":"The SQL entry's referenced database connection was deleted from the repository; repository DB unreachable; job moved between repositories where connection ids no longer match.","solutions":["Verify the database connection referenced by the SQL entry still exists in the repository.","Test repository connectivity and re-authenticate.","Check R_JOBENTRY_ATTRIBUTE rows for the given idJobentry (CONNECTION_TAG, SQLFILENAME_TAG).","Recreate the connection in Spoon and re-save the job entry."],"exampleFix":"// before\nsqlEntry.loadRep(rep, metaStore, idJobentry, databases, slaveServers);\n// after\nList<DatabaseMeta> dbs = rep != null ? rep.getDatabases() : null;\nboolean connExists = dbs != null && dbs.stream().anyMatch(d -> d.getName().equals(expectedConn));\nif (!connExists) {\n  logError(\"Connection '\" + expectedConn + \"' missing; fix before loading entry\");\n}\nsqlEntry.loadRep(rep, metaStore, idJobentry, databases, slaveServers);","handlingStrategy":"validation","validationCode":"// Ensure the referenced connection exists before loading\nList<DatabaseMeta> dbs = rep.getDatabases();\nif (dbs.stream().noneMatch(d -> d.getName().equals(expectedConnectionName))) {\n  throw new KettleException(\"Connection '\" + expectedConnectionName + \"' not found in repository\");\n}\n","typeGuard":null,"tryCatchPattern":"try {\n  sqlEntry.loadRep(rep, metaStore, idJobentry, databases, slaveServers);\n} catch (KettleException e) {\n  logError(\"Repository load failed for idJobentry=\" + idJobentry + \" cause=\" + e.getCause(), e);\n}","preventionTips":["Keep shared database connections intact when moving jobs between repositories","Test repository connectivity before batch-loading jobs","Verify connection metadata exists for every SQL entry"],"tags":["repository","pdi","job-entry","database","connection"],"backgroundTag":"database-query-failed","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"}