{"record":{"id":"d5a268502c36183f","repo":"mybatis/mybatis-3","slug":"error-setting-non-null-for-parameter-i-wi","errorCode":null,"errorMessage":"Error setting non null for parameter #\" + i + \" with JdbcType \" + jdbcType + \" . Try setting a different JdbcType for this parameter or a different configuration property. Cause: \" + e","messagePattern":"Error setting non null for parameter #\" \\+ i \\+ \" with JdbcType \" \\+ jdbcType \\+ \" \\. Try setting a different JdbcType for this parameter or a different configuration property\\. Cause: \" \\+ e","errorType":"exception","errorClass":"TypeException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/type/BaseTypeHandler.java","lineNumber":75,"sourceCode":"\n  @Override\n  public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {\n    if (parameter == null) {\n      if (jdbcType == null) {\n        throw new TypeException(\"JDBC requires that the JdbcType must be specified for all nullable parameters.\");\n      }\n      try {\n        ps.setNull(i, jdbcType.TYPE_CODE);\n      } catch (SQLException e) {\n        throw new TypeException(\"Error setting null for parameter #\" + i + \" with JdbcType \" + jdbcType + \" . \"\n            + \"Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. \"\n            + \"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 {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/type/BaseTypeHandler.java#L57-L93","documentation":"The parameter was non-null and MyBatis dispatched it to the type handler's setNonNullParameter, but that call threw (driver conversion error, data truncation, wrong handler for the value's real type). This TypeException is a wrapper: the actionable detail is always in the caused-by chain.","triggerScenarios":"A String longer than the column for setString; a handler mapped for one java type receiving another (e.g. DateTypeHandler given a LocalDate because the javaType attribute was wrong); dialect-specific setObject failures.","commonSituations":"resultMap/parameter javaType mismatches after refactoring entity fields; locale/charset data that the driver rejects; switching JDBC drivers with stricter conversion rules.","solutions":["Inspect the Cause exception — the driver message names the failing parameter and reason","Verify the #{param} javaType/typeHandler matches the actual runtime class of the argument","Fix the data or column size if the cause is truncation/conversion at the driver level"],"exampleFix":"// before\n#{createdOn,jdbcType=TIMESTAMP}  <!-- value is java.time.LocalDateTime -->\n\n// after\n#{createdOn,typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ... } catch (TypeException e) {\n  Throwable root = e; while (root.getCause() != null) root = root.getCause();\n  // root is the driver error: log parameter index i and value type, fix binding\n}","preventionTips":["Keep mapper javaType declarations in sync with entity field types","Validate field lengths/value ranges before insert/update","Log the bound parameter types when diagnosing persistent binding failures"],"tags":["mybatis","jdbc","type-handler","parameter-binding"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}