{"record":{"id":"bc49bc00e3a57200","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-value-valuemeta-from-database-resultset-index","errorCode":null,"errorMessage":"Unable to get value '<valueMeta>' from database resultset, index <index>","messagePattern":"Unable to get value '<valueMeta>' from database resultset, index <index>","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/AzureSqlDataBaseMeta.java","lineNumber":94,"sourceCode":"   * @param index\n   *          the index on which we need to retrieve the value, 0-based.\n   * @return The correctly converted Kettle data type corresponding to the valueMeta description.\n   * @throws KettleDatabaseException\n   */\n  @Override\n  public Object getValueFromResultSet( ResultSet rs, ValueMetaInterface val, int index ) throws KettleDatabaseException {\n    Object data;\n    try {\n      if ( val.getType() == ValueMetaInterface.TYPE_BINARY ) {\n        data = rs.getString( index + 1 );\n      } else {\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    return data;\n  }\n\n  @Override\n  public String getXulOverlayFile() {\n    return \"azuresqldb\";\n  }\n\n  @Override\n  public void setConnectionSpecificInfoFromAttributes( Map<String, String> attributes ) {\n    addAttribute( JDBC_AUTH_METHOD, setStringValueFromMap( attributes, JDBC_AUTH_METHOD ) );\n    addAttribute( CLIENT_ID, setStringValueFromMap( attributes, CLIENT_ID ) );\n    addAttribute( CLIENT_SECRET_KEY, setStringValueFromMap( attributes, CLIENT_SECRET_KEY ) );\n    addAttribute( IS_ALWAYS_ENCRYPTION_ENABLED, setStringValueFromMap( attributes, IS_ALWAYS_ENCRYPTION_ENABLED ) );\n  }\n}","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/AzureSqlDataBaseMeta.java#L76-L112","documentation":"AzureSqlDataBaseMeta.getValueFromResultSet extracts a typed value from a JDBC ResultSet for the given ValueMetaInterface at the given index. Any SQLException thrown during that extraction is wrapped in a KettleDatabaseException carrying the value's metadata name and the column index, so callers know which field failed.","triggerScenarios":"Reading a row from an Azure SQL query result where the JDBC driver throws SQLException on rs.getXxx(index) — e.g. type mismatch between the ValueMeta type and the actual column type, or the connection broke mid-read.","commonSituations":"Querying Azure SQL where a column's actual SQL type does not match the declared ValueMeta (e.g. reading a DATETIME2 as java.sql.Timestamp with an old driver); connection dropped during large result streaming; incompatible mssql-jdbc driver versions.","solutions":["Update the Microsoft mssql-jdbc driver to the latest version compatible with your Azure SQL server.","Ensure the row metadata (ValueMetaInterface types) matches the actual SELECT column types.","Verify the connection is still alive and increase socket/query timeouts for large result sets.","Catch KettleDatabaseException in the step processing loop and log the failing column index for diagnosis."],"exampleFix":"// before\nString sql = \"SELECT myDatetime2Col FROM t\"; // declared as Timestamp with old driver\n\n// after\nString sql = \"SELECT CAST(myDatetime2Col AS datetime) FROM t\"; // match meta type, upgrade driver","handlingStrategy":"try-catch","validationCode":"// before reading rows, confirm the value meta types match the ResultSet\nfor (int i = 0; i < rowMeta.size(); i++) {\n  int sqlType = rs.getMetaData().getColumnType(i + 1);\n  // compare with rowMeta.getValueMeta(i).getType() and fail fast on mismatch\n}","typeGuard":null,"tryCatchPattern":"try {\n  Object v = meta.getValueFromResultSet(rs, val, i);\n} catch (KettleDatabaseException e) {\n  LOG.error(\"Failed reading column index \" + i + \" (\" + val + \") from Azure SQL\", e);\n  throw e;\n}","preventionTips":["Keep the mssql-jdbc driver current for Azure SQL type support.","Align SELECT column casts with the row's ValueMetaInterface types.","Set generous socket/query timeouts for large result sets."],"tags":["database","jdbc","azure-sql","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"}