{"record":{"id":"3342826bb7d64840","repo":"flowable/flowable-engine","slug":"error-setting-null-for-parameter-i-with-jdbcty","errorCode":null,"errorMessage":"Error setting null for parameter #${i} with JdbcType ${jdbcType} . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: ${e}","messagePattern":"Error setting null for parameter #(.+?) with JdbcType (.+?) \\. Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property\\. Cause: (.+?)","errorType":"exception","errorClass":"TypeException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/FlowableStringTypeHandler.java","lineNumber":41,"sourceCode":"        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                if (useDefaultJdbcType) {\n                    JdbcType finalJdbcType = null;\n                    if (jdbcType.equals(JdbcType.NVARCHAR)) {\n                        finalJdbcType = JdbcType.VARCHAR;\n                    } else {\n                        finalJdbcType = jdbcType;\n                    }\n                    ps.setNull(i,  finalJdbcType.TYPE_CODE);\n                    \n                } else {\n                    ps.setNull(i, Types.NULL);\n                }\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 void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException {\n        ps.setString(i, parameter);\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/FlowableStringTypeHandler.java#L23-L59","documentation":"TypeException raised when ps.setNull(...) fails for a nullable String parameter in FlowableStringTypeHandler.setParameter. The handler already had a JdbcType but the driver rejected the setNull call; the message suggests choosing a different JdbcType or changing the jdbcTypeForNull configuration.","triggerScenarios":"Binding null to parameter #i throws SQLException inside setNull(i, TYPE_CODE) or setNull(i, Types.NULL): driver doesn't support Types.NULL, column type incompatible with the configured JdbcType, or driver-specific limitations (e.g. some Oracle/driver combos with certain types).","commonSituations":"jdbcTypeForNull set to NULL/OTHER on drivers that reject it; custom mappings specifying an exotic jdbcType (e.g. NVARCHAR) unsupported by the driver for setNull; non-null expectation on a NOT NULL column surfaces as SQL error surfaced through this path.","solutions":["Change jdbcTypeForNull to a widely supported type such as VARCHAR in the MyBatis configuration.","Adjust the jdbcType attribute in the mapper mapping to a type the driver accepts for setNull.","Check the cause SQLException for the column constraint (NOT NULL violation means the value must be non-null).","Update the JDBC driver to a version that handles the configured null JdbcType."],"exampleFix":"// before\nconfiguration.setJdbcTypeForNullType(JdbcType.NULL);\n// after\nconfiguration.setJdbcTypeForNullType(JdbcType.VARCHAR);","handlingStrategy":"try-catch","validationCode":"if (value == null) { /* ensure jdbcType is driver-supported: prefer VARCHAR, avoid NULL/OTHER */ }","typeGuard":null,"tryCatchPattern":"catch (TypeException e) { if (e.getMessage().startsWith(\"Error setting null\")) { log.error(\"setNull failed for param\", e.getCause()); /* switch jdbcTypeForNull */ } throw e; }","preventionTips":["Use jdbcTypeForNull=VARCHAR, not NULL/OTHER, on restrictive drivers.","Check the driver docs for supported null JdbcTypes.","Inspect cause SQLException to distinguish constraint vs. driver issues."],"tags":["mybatis","jdbc","null","database","flowable"],"backgroundTag":"sql-query-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}