{"record":{"id":"ffb944067b4903ad","repo":"apache/shardingsphere","slug":"getprecision","errorCode":null,"errorMessage":"getPrecision","messagePattern":"getPrecision","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationParameterMetaData.java","lineNumber":43,"sourceCode":"\n/**\n * Unsupported {@code ParameterMetaData} methods.\n */\npublic abstract class AbstractUnsupportedOperationParameterMetaData extends WrapperAdapter implements ParameterMetaData {\n    \n    @Override\n    public final int isNullable(final int parameter) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"isNullable\");\n    }\n    \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","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationParameterMetaData.java#L25-L61","documentation":"SQLFeatureNotSupportedException thrown by AbstractUnsupportedOperationParameterMetaData.getPrecision(int). ShardingSphere prepares SQL only in its own parser for routing; it does not push PREPARE to a backend, so the precision of a '?' parameter is unknown and this final method always throws. Only getParameterCount() is implemented by the subclass.","triggerScenarios":"ps.getParameterMetaData().getPrecision(i) on a ShardingSphere PreparedStatement. Commonly invoked by frameworks validating DECIMAL/NUMERIC bind values, e.g. BigDecimal formatting layers and some legacy EJB/JDO-style mappers.","commonSituations":"Financial/reporting apps that pre-validate BigDecimal scale/precision against ParameterMetaData before insert; migration from a driver that answered getPrecision (DB2, SQLServer, MySQL with useServerPrepStmts) to jdbc:shardingsphere:.","solutions":["Validate precision in application code or against DatabaseMetaData.getColumns of the real table, not against ParameterMetaData.","Catch SQLFeatureNotSupportedException and skip precision validation for ShardingSphere datasources (let the backend enforce it).","Route the validation query through a plain DataSource pointing at one shard if metadata accuracy is mandatory."],"exampleFix":"// before\nif (value.precision() > pmd.getPrecision(idx)) throw new IllegalArgumentException(...);\n\n// after\nif (value.precision() > columnPrecisionFromTableMetadata) throw new IllegalArgumentException(...);","handlingStrategy":"validation","validationCode":"// Pre-check driver capability instead of probing getPrecision on ShardingSphere\nString driver = conn.getMetaData().getDriverName();\nif (!driver.toLowerCase().contains(\"shardingsphere\")) { maxPrecision = pmd.getPrecision(1); } else { maxPrecision = Integer.MAX_VALUE; }","typeGuard":null,"tryCatchPattern":"try { precision = pmd.getPrecision(1); } catch (final SQLFeatureNotSupportedException e) { precision = -1; /* unknown, skip client check */ }","preventionTips":["Validate precision against your entity/table mapping, not ParameterMetaData","Let the backend enforce DECIMAL precision","Probe driver name before any per-parameter metadata call"],"tags":["jdbc","shardingsphere","parametermetadata","precision","sql-feature-not-supported"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}