{"record":{"id":"ae1fe8f5d7fe91e4","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-timestamp-from-resultset-at-index-index","errorCode":null,"errorMessage":" : Unable to get timestamp from resultset at index \" + index","messagePattern":" : Unable to get timestamp from resultset at index \" \\+ index","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java","lineNumber":521,"sourceCode":"        return valueMeta;\n      }\n\n      return null;\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Error evaluating timestamp value metadata\", e );\n    }\n  }\n\n  @Override\n  public Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index )\n    throws KettleDatabaseException {\n\n    try {\n\n      return resultSet.getTimestamp( index + 1 );\n\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException(\n        toStringMeta() + \" : Unable to get timestamp from resultset at index \" + index, e );\n    }\n  }\n\n  @Override\n  public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,\n                                         Object data ) throws KettleDatabaseException {\n\n    try {\n      if ( data != null ) {\n        preparedStatement.setTimestamp( index, getTimestamp( data ) );\n      } else {\n        preparedStatement.setNull( index, java.sql.Types.TIMESTAMP );\n      }\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( toStringMeta() + \" : Unable to set value on prepared statement on index \"\n        + index, e );\n    }","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java#L503-L539","documentation":"Thrown by ValueMetaTimestamp.getValueFromResultSet when ResultSet.getTimestamp(index+1) throws, preventing the timestamp column value from being read. The message includes the field metadata and the 0-based index.","triggerScenarios":"Reading a query result row where the column at the given index is not a timestamp-compatible type, the value is out of the driver's supported range, or the result set/connection is in an invalid state.","commonSituations":"SELECT of a non-timestamp column mapped to a Timestamp value meta (column order drift after query edits), reading TIMESTAMP WITH TIME ZONE from drivers that can't convert, pre-1582 or out-of-range dates.","solutions":["Re-run 'Get Fields' so the row metadata column order matches the SELECT statement","Check the chained cause for the driver error message","Cast the column in SQL (e.g. CAST(col AS TIMESTAMP)) to a convertible type","Verify the index passed matches the 0-based column position"],"exampleFix":"// before\nSELECT id, some_varchar FROM t; // read as timestamp at index 1\n// after\nSELECT id, CAST(some_varchar AS TIMESTAMP) AS ts FROM t;","handlingStrategy":"try-catch","validationCode":"ResultSetMetaData md = rs.getMetaData();\nif (index + 1 > md.getColumnCount()) throw new IllegalArgumentException(\"Index \" + index + \" outside result set\");\nif (md.getColumnType(index + 1) != java.sql.Types.TIMESTAMP && md.getColumnType(index + 1) != java.sql.Types.DATE) {\n  throw new IllegalStateException(\"Column \" + (index + 1) + \" is not a timestamp type\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  Timestamp ts = (Timestamp) rsMeta.getValueFromResultSet(dbInterface, resultSet, index);\n} catch (KettleDatabaseException e) {\n  logError(\"Failed reading timestamp at index \" + index + \": \" + e.getCause());\n  ts = null; // or re-map column order and retry\n}","preventionTips":["Regenerate row metadata after any change to the SELECT column list","Never assume column order — resolve indexes by column name","Cast exotic types (TIMESTAMP WITH TIME ZONE) in SQL before reading","Check the driver's supported timestamp range for very old dates"],"tags":["pdi","database","jdbc","resultset"],"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"}