pentaho/pentaho-kettle · error · KettleException

Unable to save job entry of type 'sql' to the repository…

Error message

Unable to save job entry of type 'sql' to the repository for idJob=

What it means

KettleException thrown by JobEntrySQL.saveRep when saving the 'sql' job entry's attributes (useVariableSubstitution, sqlFromFile, sqlFilename, sendOneStatement, plus SQL and connection) to the repository fails with a KettleDatabaseException. The message carries idJob to locate the failing job.

Solutions

  1. Inspect the wrapped KettleDatabaseException cause for the actual SQL error.
  2. Confirm the repository database is writable and the session is still valid.
  3. Check value size limits (e.g. large SQL against VALUE_NUM/VALUE_STR column sizes).
  4. Upgrade the repository schema to match the current Pentaho version and retry.

Example fix

// before
sqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);
// after
try {
  sqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);
} catch (KettleException e) {
  logError("Could not save SQL entry for job " + idJob + ": " + e.getCause(), e);
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (rep == null || idJob == null) throw new IllegalArgumentException("Repository and idJob are required");
// ensure entry has an ObjectId before saving attributes
if (sqlEntry.getObjectId() == null) throw new KettleException("Entry must be persisted before saveRep");

Try / catch

try {
  sqlEntry.saveRep(rep, metaStore, idJob, databases, slaveServers);
} catch (KettleException e) {
  logError("Save failed for idJob=" + idJob + " cause=" + e.getCause(), e);
  throw e; // fail the overall job save
}

Prevention

When it happens

Trigger: Calling saveRep for a 'sql' job entry when any saveJobEntryAttribute call raises KettleDatabaseException: repository write failure, constraint violation, connection loss, or read-only database.

Common situations: Repository session expired mid-save; DB in read-only mode; schema version mismatch; very large SQL text exceeding column size limits in R_JOBENTRY_ATTRIBUTE.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/job/entries/sql/JobEntrySQL.java:183

      throw new KettleException( "Unable to load job entry of type 'sql' from the repository with idJobentry="
        + idJobentry, dbe );
    }
  }

  // Save the attributes of this job entry
  //
  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId idJob ) throws KettleException {
    try {
      rep.saveDatabaseMetaJobEntryAttribute( idJob, getObjectId(), CONNECTION_TAG, ID_DATABASE, databaseMeta );

      rep.saveJobEntryAttribute( idJob, getObjectId(), SQL_TAG, sql );
      rep.saveJobEntryAttribute( idJob, getObjectId(), USE_VARIABLE_SUBSTITUTION_TAG, useVariableSubstitution
        ? "T" : "F" );
      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFROMFILE_TAG, sqlFromFile ? "T" : "F" );
      rep.saveJobEntryAttribute( idJob, getObjectId(), SQLFILENAME_TAG, sqlFilename );
      rep.saveJobEntryAttribute( idJob, getObjectId(), SEND_ONE_STATEMENT_TAG, sendOneStatement ? "T" : "F" );
    } catch ( KettleDatabaseException dbe ) {
      throw new KettleException(
        "Unable to save job entry of type 'sql' to the repository for idJob=" + idJob, dbe );
    }
  }

  public void setSQL( String sql ) {
    this.sql = sql;
  }

  public String getSQL() {
    return sql;
  }

  public String getSQLFilename() {
    return sqlFilename;
  }

  public void setSQLFilename( String sqlFilename ) {
    this.sqlFilename = sqlFilename;

View on GitHub (pinned to f3058517a1)