{"record":{"id":"b24ed27fc89c215c","repo":"mybatis/mybatis-3","slug":"error-attempting-to-get-column-columnname","errorCode":null,"errorMessage":"Error attempting to get column '\" + columnName + \"' from result set.  Cause: \" + e","messagePattern":"Error attempting to get column '\" \\+ columnName \\+ \"' from result set\\.  Cause: \" \\+ e","errorType":"exception","errorClass":"ResultMapException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/type/BaseTypeHandler.java","lineNumber":87,"sourceCode":"            + \"Cause: \" + e, e);\n      }\n    } else {\n      try {\n        setNonNullParameter(ps, i, parameter, jdbcType);\n      } catch (Exception e) {\n        throw new TypeException(\"Error setting non null for parameter #\" + i + \" with JdbcType \" + jdbcType + \" . \"\n            + \"Try setting a different JdbcType for this parameter or a different configuration property. \" + \"Cause: \"\n            + e, e);\n      }\n    }\n  }\n\n  @Override\n  public T getResult(ResultSet rs, String columnName) throws SQLException {\n    try {\n      return getNullableResult(rs, columnName);\n    } catch (Exception e) {\n      throw new ResultMapException(\"Error attempting to get column '\" + columnName + \"' from result set.  Cause: \" + e,\n          e);\n    }\n  }\n\n  @Override\n  public T getResult(ResultSet rs, int columnIndex) throws SQLException {\n    try {\n      return getNullableResult(rs, columnIndex);\n    } catch (Exception e) {\n      throw new ResultMapException(\"Error attempting to get column #\" + columnIndex + \" from result set.  Cause: \" + e,\n          e);\n    }\n  }\n\n  @Override\n  public T getResult(CallableStatement cs, int columnIndex) throws SQLException {\n    try {\n      return getNullableResult(cs, columnIndex);","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/type/BaseTypeHandler.java#L69-L105","documentation":"BaseTypeHandler.getResult(rs, columnName) wraps every exception thrown while reading a column from the ResultSet via getNullableResult. The failure is either the driver reporting 'column not found' (SQL alias / resultMap mismatch) or a type conversion failure inside the concrete handler.","triggerScenarios":"A resultMap or auto-mapping references a column name that the SELECT does not return (missing alias, typo, column removed from query); or the handler mapped for the property cannot convert the column value (e.g. reading a non-numeric string as Integer).","commonSituations":"Changing the SELECT list without updating the resultMap; DB views/queries whose column casing differs (Oracle upper-cases unquoted identifiers); handler mismatch after changing a property type.","solutions":["Match the resultMap column attribute to the exact column label the query returns (add an SQL alias if needed)","Check the Cause for a 'column not found' vs conversion error and fix the query or the property type accordingly","For Oracle unquoted identifiers, use the upper-cased column name in the resultMap"],"exampleFix":"// before\nSELECT name AS userName ...  <result column=\"name\" property=\"userName\"/>\n\n// after\nSELECT name AS userName ...  <result column=\"userName\" property=\"userName\"/>","handlingStrategy":"try-catch","validationCode":"// verify expected columns exist before mapping\nResultSetMetaData md = rs.getMetaData();\nSet<String> cols = new HashSet<>();\nfor (int i = 1; i <= md.getColumnCount(); i++) cols.add(md.getColumnLabel(i).toUpperCase());\nif (!cols.contains(\"USERNAME\")) throw new IllegalStateException(\"column USERNAME missing\");","typeGuard":null,"tryCatchPattern":"try { ... } catch (ResultMapException e) { // e names the column; compare with the SELECT's aliases and fix the resultMap }","preventionTips":["Always alias computed/renamed columns in SELECT and reference the same alias in resultMap","Integration-test every resultMap against the real query","Beware identifier casing per database (Oracle upper-case) — use consistent aliases"],"tags":["mybatis","resultset","resultmap","column-mapping"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}