{"record":{"id":"55cc8aed336320c9","repo":"tursodatabase/turso","slug":"column-name-not-found","errorCode":null,"errorMessage":"column name not found","messagePattern":"column name not found","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/jdbc4/JDBC4ResultSet.java","lineNumber":434,"sourceCode":"  }\n\n  @Override\n  public Object getObject(int columnIndex) throws SQLException {\n    final Object result = resultSet.get(columnIndex);\n    wasNull = result == null;\n    return result;\n  }\n\n  @Override\n  @SkipNullableCheck\n  public Object getObject(String columnLabel) throws SQLException {\n    return getObject(findColumn(columnLabel));\n  }\n\n  @Override\n  public int findColumn(String columnLabel) throws SQLException {\n    if (columnLabel == null || columnLabel.isEmpty()) {\n      throw new SQLException(\"column name not found\");\n    }\n\n    final String[] columnNames = resultSet.getColumnNames();\n    for (int i = 0; i < columnNames.length; i++) {\n      if (columnNames[i].equals(columnLabel)) {\n        return i + 1;\n      }\n    }\n    throw new SQLException(\"column name \" + columnLabel + \" not found\");\n  }\n\n  @Override\n  @SkipNullableCheck\n  public Reader getCharacterStream(int columnIndex) throws SQLException {\n    final Object result = resultSet.get(columnIndex);\n    wasNull = result == null;\n    if (result == null) {\n      return null;","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/java/src/main/java/tech/turso/jdbc4/JDBC4ResultSet.java#L416-L452","documentation":"findColumn() throws 'column name not found' before even scanning the columns when the label is null or empty. Every label-based getter (getString(String), getInt(String), getDate(String), ...) routes through findColumn, so a blank label surfaces from any of them.","triggerScenarios":"rs.getX(null) or rs.getX(\"\") - usually a label variable that was never set: a Map.get() miss, a config key typo, or a string built by concatenation that came out empty.","commonSituations":"Column names driven by configuration or user input; refactors that leave constants null; whitespace-only labels trimmed to empty; loop variables over a sparse key map.","solutions":["Guard the label before use: reject null/empty with a clear IllegalArgumentException naming the caller","Switch to ordinal access (rs.getX(1)) when the label cannot be trusted","Log the label at the call site so blank values are visible when the failure happens"],"exampleFix":"// before\nreturn rs.getString(columnName); // columnName == null -> \"column name not found\"\n\n// after\nif (columnName == null || columnName.isEmpty()) {\n  throw new IllegalArgumentException(\"column label must be set, got: \" + columnName);\n}\nreturn rs.getString(columnName);","handlingStrategy":"validation","validationCode":"// Validate before any label-based getter (they all route through findColumn)\nif (label == null || label.isEmpty()) {\n  throw new IllegalArgumentException(\"column label required, got: \" + label);\n}","typeGuard":"static boolean usableLabel(String label) {\n  return label != null && !label.isEmpty();\n}","tryCatchPattern":"try {\n  int idx = rs.findColumn(label);\n} catch (SQLException e) {\n  if (!String.valueOf(e.getMessage()).startsWith(\"column name\")) throw e;\n  throw new IllegalStateException(\"blank or null column label at this call site\", e);\n}","preventionTips":["Never pass computed labels to label-based getters without a null/empty check","Fail fast on blank labels with IllegalArgumentException, which names the caller"],"tags":["java","jdbc","turso","column-lookup","validation"],"backgroundTag":"jdbc-column-not-found","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}