pentaho/pentaho-kettle · error · KettleDatabaseException

: Unable to get timestamp from resultset at index " + index

Error message

 : Unable to get timestamp from resultset at index " + index

What it means

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.

Solutions

  1. Re-run 'Get Fields' so the row metadata column order matches the SELECT statement
  2. Check the chained cause for the driver error message
  3. Cast the column in SQL (e.g. CAST(col AS TIMESTAMP)) to a convertible type
  4. Verify the index passed matches the 0-based column position

Example fix

// before
SELECT id, some_varchar FROM t; // read as timestamp at index 1
// after
SELECT id, CAST(some_varchar AS TIMESTAMP) AS ts FROM t;
Defensive patterns

Strategy: try-catch

Validate before calling

ResultSetMetaData md = rs.getMetaData();
if (index + 1 > md.getColumnCount()) throw new IllegalArgumentException("Index " + index + " outside result set");
if (md.getColumnType(index + 1) != java.sql.Types.TIMESTAMP && md.getColumnType(index + 1) != java.sql.Types.DATE) {
  throw new IllegalStateException("Column " + (index + 1) + " is not a timestamp type");
}

Try / catch

try {
  Timestamp ts = (Timestamp) rsMeta.getValueFromResultSet(dbInterface, resultSet, index);
} catch (KettleDatabaseException e) {
  logError("Failed reading timestamp at index " + index + ": " + e.getCause());
  ts = null; // or re-map column order and retry
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java:521

        return valueMeta;
      }

      return null;
    } catch ( Exception e ) {
      throw new KettleDatabaseException( "Error evaluating timestamp value metadata", e );
    }
  }

  @Override
  public Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index )
    throws KettleDatabaseException {

    try {

      return resultSet.getTimestamp( index + 1 );

    } catch ( Exception e ) {
      throw new KettleDatabaseException(
        toStringMeta() + " : Unable to get timestamp from resultset at index " + index, e );
    }
  }

  @Override
  public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
                                         Object data ) throws KettleDatabaseException {

    try {
      if ( data != null ) {
        preparedStatement.setTimestamp( index, getTimestamp( data ) );
      } else {
        preparedStatement.setNull( index, java.sql.Types.TIMESTAMP );
      }
    } catch ( Exception e ) {
      throw new KettleDatabaseException( toStringMeta() + " : Unable to set value on prepared statement on index "
        + index, e );
    }

View on GitHub (pinned to f3058517a1)