{"record":{"id":"34c15dfdcbf9723d","repo":"pentaho/pentaho-kettle","slug":"conversion-error-after-getting-last-logdate-from-0","errorCode":null,"errorMessage":"Conversion error after getting last logdate from {0}","messagePattern":"Conversion error after getting last logdate from (.+?)","errorType":"exception","errorClass":"KettleJobException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/Job.java","lineNumber":1045,"sourceCode":"\n      try {\n        // See if we have to add a batch id...\n        Long id_batch = 1L;\n        if ( jobMeta.getJobLogTable().isBatchIdUsed() ) {\n          id_batch = logcon.getNextBatchId( ldb, schemaName, tableName, jobLogTable.getKeyField().getFieldName() );\n          setBatchId( id_batch.longValue() );\n          if ( getPassedBatchId() <= 0 ) {\n            setPassedBatchId( id_batch.longValue() );\n          }\n        }\n\n        Object[] lastr = ldb.getLastLogDate( schemaAndTable, jobMeta.getName(), true, LogStatus.END );\n        if ( !Utils.isEmpty( lastr ) ) {\n          Date last;\n          try {\n            last = ldb.getReturnRowMeta().getDate( lastr, 0 );\n          } catch ( KettleValueException e ) {\n            throw new KettleJobException( BaseMessages.getString( PKG, \"Job.Log.ConversionError\", \"\" + tableName ), e );\n          }\n          if ( last != null ) {\n            startDate = last;\n          }\n        }\n\n        depDate = currentDate;\n\n        ldb.writeLogRecord( jobMeta.getJobLogTable(), LogStatus.START, this, null );\n        if ( !ldb.isAutoCommit() ) {\n          ldb.commitLog( true, jobMeta.getJobLogTable() );\n        }\n        ldb.close();\n\n        // If we need to do periodic logging, make sure to install a timer for\n        // this...\n        //\n        if ( intervalInSeconds > 0 ) {","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/Job.java#L1027-L1063","documentation":"Thrown in the Job constructor when reading the last END log date from the job log table fails conversion. The value retrieved from the database cannot be converted to a Date via the row metadata (KettleValueException), so the constructor aborts with a KettleJobException.","triggerScenarios":"getReturnRowMeta().getDate(row, 0) throws because the first column of the getLastLogDate result is not a Date-compatible value.","commonSituations":"Custom/shared log table schemas where LOGDATE is stored as VARCHAR or wrong type; database returning dates in an unexpected format/driver type; pointing a job at a log table created by another tool.","solutions":["Ensure the log table's LOGDATE column is a TIMESTAMP/DATETIME type","Recreate the log table using Kettle's DDL generation","Verify the database driver returns proper date types (update JDBC driver)","Inspect ldb.getReturnRowMeta() to see the expected type vs actual column type"],"exampleFix":"// before\nCREATE TABLE job_log (... LOGDATE VARCHAR(50) ...)\n// after\nCREATE TABLE job_log (... LOGDATE TIMESTAMP ...)","handlingStrategy":"validation","validationCode":"// check log table column type before running\nResultSet rs = conn.getMetaData().getColumns(null, schema, tableName, \"LOGDATE\");\nif (!rs.next() || !rs.getString(\"TYPE_NAME\").toUpperCase().contains(\"TIMESTAMP\")) {\n  throw new IllegalStateException(\"LOGDATE column must be TIMESTAMP\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Job job = new Job(...);\n} catch (KettleJobException e) {\n  if (e.getMessage().startsWith(\"Conversion error after getting last logdate\")) {\n    log.error(\"Job log table LOGDATE column has wrong type; recreate log table\", e);\n  }\n}","preventionTips":["Generate log table DDL from Kettle rather than hand-writing it","Keep LOGDATE as TIMESTAMP/DATETIME in all log tables","Use a current JDBC driver that maps dates properly","Don't share log tables across unrelated tools with different schemas"],"tags":["database","logging","type-conversion"],"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"}