{"record":{"id":"acbcb72381bbe717","repo":"apache/shardingsphere","slug":"getwarnings-acbcb7","errorCode":null,"errorMessage":"getWarnings","messagePattern":"getWarnings","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":152,"sourceCode":"    \n    @Override\n    public final InputStream getUnicodeStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getUnicodeStream\");\n    }\n    \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","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L134-L170","documentation":"ShardingSphere's GeneratedKeysResultSet (returned by getGeneratedKeys()) inherits getWarnings() as an unconditional SQLFeatureNotSupportedException(\"getWarnings\") throw (AbstractUnsupportedGeneratedKeysResultSet:152). The synthesized key result set never accumulates SQLWarnings, so the warning chain API is closed off rather than returning null.","triggerScenarios":"Calling resultSet.getWarnings() on the ResultSet from Statement.getGeneratedKeys() or PreparedStatement.getGeneratedKeys() — commonly inside strict JDBC compliance wrappers, monitoring agents (e.g. P6Spy-style interceptors), or code that drains warnings after each row batch.","commonSituations":"JDBC monitoring/proxy layers and connection pools that call getWarnings() on every result set they manage; frameworks doing strict warning scans (some test harnesses assert null warnings); apps that previously used a native driver where getWarnings() returned null on generated keys and only failed after moving to ShardingSphere-JDBC.","solutions":["Guard the call: skip getWarnings() when the result set came from getGeneratedKeys() (check rs.getMetaData().getColumnCount() == 1 and the statement context, or simply don't warn-scan key result sets).","Catch SQLFeatureNotSupportedException and treat it as 'no warnings' if you cannot change the call site.","In wrappers/agents, feature-detect once with a cheap probe and remember that this result set class does not support warnings.","Retrieve warnings from the Statement/Connection level instead if warning collection matters to you."],"exampleFix":"// before\nSQLWarning w = rs.getWarnings();\n\n// after\nSQLWarning w;\ntry {\n    w = rs.getWarnings();\n} catch (SQLFeatureNotSupportedException e) {\n    w = null; // generated-keys result set does not support warnings\n}","handlingStrategy":"try-catch","validationCode":"// getMetaData() is supported: use it to detect the single-column key result set before warning scans\nif (keys.getMetaData().getColumnCount() > 1) {\n    SQLWarning w = keys.getWarnings();\n}","typeGuard":"private static boolean supportsWarnings(ResultSet rs) {\n    return !rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"SQLWarning w = null;\ntry {\n    w = rs.getWarnings();\n} catch (SQLFeatureNotSupportedException e) {\n    // treat as no warnings\n}","preventionTips":["Do not warning-scan generated-keys result sets in monitoring layers.","Collect warnings at Statement/Connection level instead.","Feature-probe result-set capabilities once and cache per class."],"tags":["jdbc","shardingsphere","generated-keys","warnings","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}