{"record":{"id":"fc452ebbfed462b3","repo":"apache/shardingsphere","slug":"getfetchdirection","errorCode":null,"errorMessage":"getFetchDirection","messagePattern":"getFetchDirection","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":177,"sourceCode":"    \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\n    public final int getFetchDirection() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getFetchDirection\");\n    }\n    \n    @Override\n    public final void setFetchSize(final int rows) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setFetchSize\");\n    }\n    \n    @Override\n    public final int getFetchSize() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getFetchSize\");\n    }\n    \n    @Override\n    public final Blob getBlob(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBlob\");\n    }\n    \n    @Override","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L159-L195","documentation":"getFetchDirection() throws SQLFeatureNotSupportedException(\"getFetchDirection\") unconditionally in AbstractUnsupportedGeneratedKeysResultSet:177, which GeneratedKeysResultSet (the getGeneratedKeys() result of ShardingSphere's driver) extends. Since no direction can be set, querying it is likewise closed off instead of returning FETCH_FORWARD.","triggerScenarios":"Calling resultSet.getFetchDirection() on the keys ResultSet — common in JDBC wrappers, data-access templates, and diagnostic/audit code that records the fetch mode of every result set.","commonSituations":"Generic data-access layers that branch on fetch direction before iterating; monitoring agents logging result-set configuration; previously-working code against a native driver that returned FETCH_FORWARD, failing after migration to ShardingSphere-JDBC.","solutions":["Remove or skip getFetchDirection() for generated-keys result sets; assume FETCH_FORWARD semantics.","Catch SQLFeatureNotSupportedException and default to ResultSet.FETCH_FORWARD when introspecting generic result sets.","Feature-probe once per result-set class in wrapper libraries and cache the answer.","Keep direction logic on the Statement/normal query ResultSet where it is supported."],"exampleFix":"// before\nint dir = rs.getFetchDirection();\n\n// after\nint dir;\ntry {\n    dir = rs.getFetchDirection();\n} catch (SQLFeatureNotSupportedException e) {\n    dir = ResultSet.FETCH_FORWARD;\n}","handlingStrategy":"try-catch","validationCode":"Object target = stmt.unwrap(org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.class);\n// simpler: only introspect fetch direction on query result sets","typeGuard":"private static boolean supportsFetchHints(ResultSet rs) {\n    return !rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"int dir;\ntry {\n    dir = rs.getFetchDirection();\n} catch (SQLFeatureNotSupportedException e) {\n    dir = ResultSet.FETCH_FORWARD;\n}","preventionTips":["Don't log/branch on fetch direction for key result sets.","Default to FETCH_FORWARD when introspection is unsupported.","Cache capability probes in JDBC wrappers."],"tags":["jdbc","shardingsphere","generated-keys","fetch-direction","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}