{"record":{"id":"6605232ba949f45e","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-value-val-tostringmeta-from-database-resultset-660523","errorCode":null,"errorMessage":"Unable to get value '\" + val.toStringMeta() + \"' from database resultset, index \" + index","messagePattern":"Unable to get value '\" \\+ val\\.toStringMeta\\(\\) \\+ \"' from database resultset, index \" \\+ index","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Vertica5DatabaseMeta.java","lineNumber":90,"sourceCode":"        case ValueMetaInterface.TYPE_DATE:\n          if ( val.getOriginalColumnType() == java.sql.Types.TIMESTAMP ) {\n            data = rs.getTimestamp( index + 1 );\n            break; // Timestamp extends java.util.Date\n          } else if ( val.getOriginalColumnType() == java.sql.Types.TIME ) {\n            data = rs.getTime( index + 1 );\n            break;\n          } else {\n            data = rs.getDate( index + 1 );\n            break;\n          }\n        default:\n          return super.getValueFromResultSet( rs, val, index );\n      }\n      if ( rs.wasNull() ) {\n        data = null;\n      }\n    } catch ( SQLException e ) {\n      throw new KettleDatabaseException( \"Unable to get value '\"\n        + val.toStringMeta() + \"' from database resultset, index \" + index, e );\n    }\n\n    return data;\n  }\n}\n","sourceCodeStart":72,"sourceCodeEnd":97,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Vertica5DatabaseMeta.java#L72-L97","documentation":"Vertica5DatabaseMeta.getValueFromResultSet wraps SQLExceptions raised while reading a typed column from a Vertica result set into this KettleDatabaseException, naming the value's metadata representation and the index. Types not handled by this subclass fall back to super.getValueFromResultSet; any SQL error during retrieval triggers this message.","triggerScenarios":"Reading row values from a Vertica result set where rs.getXXX for the declared value type throws SQLException — invalid index, type mismatch (e.g. Vertica-specific types like TIMESTAMP/TIME with scale handled incorrectly), or connection loss.","commonSituations":"Table input steps over Vertica with unusual column types; schema drift between the ValueMeta and the actual query output; large batches interrupted by network problems.","solutions":["Inspect the chained SQLException for the driver-level cause","Align the ValueMeta type with the actual Vertica column type in the query","Verify the index is within the result set's column count and the connection remains valid during iteration"],"exampleFix":"// before\nValueMetaInterface vm = new ValueMeta(\"ts\", ValueMetaInterface.TYPE_TIMESTAMP); // mismatched against Vertica column\n// after\nValueMetaInterface vm = new ValueMeta(\"ts\", ValueMetaInterface.TYPE_DATE); // type matching the actual Vertica column type\n","handlingStrategy":"try-catch","validationCode":"if (index < 0 || index >= rowMeta.size()) throw new IllegalArgumentException(\"Value index \" + index + \" outside row layout of size \" + rowMeta.size());","typeGuard":"function canReadValue(ResultSet rs, int index) { try { return rs != null && index >= 1 && index <= rs.getMetaData().getColumnCount(); } catch (SQLException e) { return false; } }","tryCatchPattern":"try {\n  Object data = vertica5Meta.getValueFromResultSet(rs, val, index);\n} catch (KettleDatabaseException e) {\n  SQLException sql = (SQLException) e.getCause(); // driver error: index vs type mismatch\n  log.error(\"Could not read Vertica value \" + val.toStringMeta() + \" at index \" + index + \": \" + (sql != null ? sql.getMessage() : e.getMessage()), e);\n}","preventionTips":["Map Vertica column types to the correct Kettle ValueMeta types","Validate indices against result set column count before reading","Re-verify row metadata after any change to the underlying query schema"],"tags":["jdbc","vertica","resultset","type-mismatch"],"backgroundTag":"sql-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"}