{"record":{"id":"3f589fd788a75f05","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-value-val-tostringmeta-from-database-resultset","errorCode":null,"errorMessage":"Unable to get value '\" + val.toStringMeta() + \"' from database resultset, index \" + i","messagePattern":"Unable to get value '\" \\+ val\\.toStringMeta\\(\\) \\+ \"' from database resultset, index \" \\+ i","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/NeoviewDatabaseMeta.java","lineNumber":457,"sourceCode":"            // Neoview can not handle getDate / getTimestamp for a Time column\n            data = rs.getTime( i + 1 );\n            break; // Time is a subclass of java.util.Date, the default date\n                   // will be 1970-01-01\n          } else if ( val.getPrecision() != 1 && supportsTimeStampToDateConversion() ) {\n            data = rs.getTimestamp( i + 1 );\n            break; // Timestamp extends java.util.Date\n          } else {\n            data = rs.getDate( i + 1 );\n            break;\n          }\n        default:\n          break;\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 \" + i, e );\n    }\n\n    return data;\n  }\n\n}\n","sourceCodeStart":439,"sourceCodeEnd":465,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/NeoviewDatabaseMeta.java#L439-L465","documentation":"NeoviewDatabaseMeta.getValueFromResultSet throws this KettleDatabaseException when a SQLException occurs while converting a result set column into a Kettle Value. The message names the value's metadata representation (val.toStringMeta()) and the 0-based index, with the SQLException chained as cause.","triggerScenarios":"Calling rs.getXXX(...) for the value's type on a Neoview result set and the driver raises SQLException — bad index, type mismatch between declared and requested type, or connection loss mid-read.","commonSituations":"Row-reading loops during table input/preview steps; schema changed so a column's type no longer matches the ValueMeta; index computed off a stale row layout.","solutions":["Check the chained SQLException for the true driver error (invalid index vs type mismatch)","Ensure the ValueMeta type matches the actual column type returned by the query","Validate index is within the result set's column count and the connection stayed alive during row iteration"],"exampleFix":"// before\nint idx = i - 1; // wrong off-by-one for 1-based JDBC\nObject v = getValueFromResultSet(rs, val, idx);\n// after\nObject v = getValueFromResultSet(rs, val, i); // 0-based index expected by this API, computed from the actual row metadata\n","handlingStrategy":"try-catch","validationCode":"if (i < 0 || i >= rowMeta.size()) throw new IllegalArgumentException(\"Value index \" + i + \" 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 = neoviewMeta.getValueFromResultSet(rs, val, i);\n} catch (KettleDatabaseException e) {\n  SQLException sql = (SQLException) e.getCause(); // inspect driver error: bad index vs type mismatch\n  log.error(\"Could not read value \" + val.toStringMeta() + \" at index \" + i + \": \" + (sql != null ? sql.getMessage() : e.getMessage()), e);\n}","preventionTips":["Keep the ValueMeta type aligned with the query's column types","Validate index against the actual result set column count","Handle connection drops during long row iterations with retry/reconnect logic"],"tags":["jdbc","resultset","sql","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"}