{"record":{"id":"4425f0839a4abdf9","repo":"apache/shardingsphere","slug":"clearwarnings-4425f0","errorCode":null,"errorMessage":"clearWarnings","messagePattern":"clearWarnings","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":157,"sourceCode":"    \n    @Override\n    public final InputStream getBinaryStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBinaryStream\");\n    }\n    \n    @Override\n    public final InputStream getBinaryStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBinaryStream\");\n    }\n    \n    @Override\n    public final SQLWarning getWarnings() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getWarnings\");\n    }\n    \n    @Override\n    public final void clearWarnings() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"clearWarnings\");\n    }\n    \n    @Override\n    public final Reader getCharacterStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getCharacterStream\");\n    }\n    \n    @Override\n    public final Reader getCharacterStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getCharacterStream\");\n    }\n    \n    @Override\n    public final void setFetchDirection(final int direction) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setFetchDirection\");\n    }\n    \n    @Override","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L139-L175","documentation":"clearWarnings() on ShardingSphere's generated-keys ResultSet always throws SQLFeatureNotSupportedException(\"clearWarnings\") (AbstractUnsupportedGeneratedKeysResultSet:157). Because the synthesized key result set neither stores nor tracks warnings, clearing them is defined as unsupported, mirroring getWarnings() on the line above.","triggerScenarios":"Calling resultSet.clearWarnings() on the result of Statement.getGeneratedKeys()/PreparedStatement.getGeneratedKeys() — frequently executed by pooled-connection reset logic, ORM session flushes, or generic 'cleanup result set' helpers that clear warnings after processing.","commonSituations":"Connection pools and transaction managers that reset warning state on every statement/result set they recycle; frameworks with a finally-block hygiene routine calling clearWarnings(); the failure appearing only after introducing ShardingSphere-JDBC into a stack that previously used a plain driver.","solutions":["Remove clearWarnings() from cleanup paths for generated-keys result sets; it is a no-op semantically there anyway.","Wrap the call in try-catch (SQLFeatureNotSupportedException) inside generic hygiene helpers and ignore it for this result set type.","Call clearWarnings() on the Statement or Connection instead, where it is supported.","If you maintain a JDBC wrapper library, feature-detect with a single probe call and cache the capability per result-set class."],"exampleFix":"// before\nrs.clearWarnings();\n\n// after\ntry {\n    rs.clearWarnings();\n} catch (SQLFeatureNotSupportedException ignore) {\n    // generated-keys result set tracks no warnings\n}","handlingStrategy":"try-catch","validationCode":"// only clear warnings on result sets known to support them (not generated-keys ones)\nif (!keys.getClass().getName().endsWith(\"GeneratedKeysResultSet\")) {\n    keys.clearWarnings();\n}","typeGuard":"private static boolean supportsWarnings(ResultSet rs) {\n    return !rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    rs.clearWarnings();\n} catch (SQLFeatureNotSupportedException ignore) {\n    // no warning state exists on this result set\n}","preventionTips":["Keep clearWarnings() out of finally-block hygiene for key result sets.","Reset warning state on Connection, not on each ResultSet.","Audit connection-pool customizers for per-result-set warning resets."],"tags":["jdbc","shardingsphere","generated-keys","warnings","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}