{"record":{"id":"a3761263d38415cc","repo":"apache/shardingsphere","slug":"getparametertype","errorCode":null,"errorMessage":"getParameterType","messagePattern":"getParameterType","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationParameterMetaData.java","lineNumber":53,"sourceCode":"    \n    @Override\n    public final boolean isSigned(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"isSigned\");\n    }\n    \n    @Override\n    public final int getPrecision(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getPrecision\");\n    }\n    \n    @Override\n    public final int getScale(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getScale\");\n    }\n    \n    @Override\n    public final int getParameterType(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getParameterType\");\n    }\n    \n    @Override\n    public final String getParameterTypeName(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getParameterTypeName\");\n    }\n    \n    @Override\n    public final String getParameterClassName(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getParameterClassName\");\n    }\n    \n    @Override\n    public final int getParameterMode(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getParameterMode\");\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationParameterMetaData.java#L35-L71","documentation":"SQLFeatureNotSupportedException thrown by AbstractUnsupportedOperationParameterMetaData.getParameterType(int). ShardingSphere parses SQL locally for sharding/encryption routing and never performs a backend PREPARE, so the java.sql.Types code of each '?' is unknown; the concrete ShardingSphereParameterMetaData only implements getParameterCount(), leaving this final throwing method.","triggerScenarios":"ps.getParameterMetaData().getParameterType(i) on ShardingSphere JDBC. Most common real trigger: MyBatis UnknownTypeHandler (used when a #{} parameter has no explicit javaType/jdbcType) calls getParameterType to choose a TypeHandler.","commonSituations":"MyBatis mappers with untyped #{param} placeholders (especially null-valued parameters or Object-typed fields) after introducing the ShardingSphere driver; generic query frameworks (Apache DbUtils, Spring SimpleJdbcInsert in some modes) that auto-detect bind types.","solutions":["Declare jdbcType/javaType explicitly in mappings: MyBatis #{name,jdbcType=INTEGER}, and set jdbcTypeForNull=NULL in mybatis-config when binding nulls.","Avoid UnknownTypeHandler: register concrete typeHandlers for the parameter's Java type so getParameterType is never consulted.","Catch SQLFeatureNotSupportedException in generic layers and default to Types.VARCHAR or a caller-supplied type hint."],"exampleFix":"<!-- before -->\n<select id=\"getUser\">SELECT * FROM user WHERE status = #{status}</select>\n\n<!-- after -->\n<select id=\"getUser\">SELECT * FROM user WHERE status = #{status,jdbcType=TINYINT}</select>","handlingStrategy":"validation","validationCode":"// MyBatis: prevent UnknownTypeHandler from ever calling getParameterType\n// mybatis-config.xml: always declare jdbcType per parameter\n<settings><setting name=\"jdbcTypeForNull\" value=\"NULL\"/></settings>","typeGuard":null,"tryCatchPattern":"try { sqlType = pmd.getParameterType(1); } catch (final SQLFeatureNotSupportedException e) { sqlType = Types.VARCHAR; /* conservative default */ }","preventionTips":["Declare jdbcType/javaType on every #{} parameter in MyBatis mappers","Avoid UnknownTypeHandler for Object-typed fields","Default null binds to jdbcType=NULL"],"tags":["jdbc","shardingsphere","mybatis","parametermetadata","sql-feature-not-supported"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}