{"record":{"id":"4a9976499daf5932","repo":"apache/shardingsphere","slug":"first","errorCode":null,"errorMessage":"first","messagePattern":"first","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java","lineNumber":70,"sourceCode":"    \n    @Override\n    public final boolean isLast() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"isLast\");\n    }\n    \n    @Override\n    public final void beforeFirst() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"beforeFirst\");\n    }\n    \n    @Override\n    public final void afterLast() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"afterLast\");\n    }\n    \n    @Override\n    public final boolean first() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"first\");\n    }\n    \n    @Override\n    public final boolean last() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"last\");\n    }\n    \n    @Override\n    public final boolean absolute(final int row) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"absolute\");\n    }\n    \n    @Override\n    public final boolean relative(final int rows) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"relative\");\n    }\n    \n    @Override","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java#L52-L88","documentation":"first() moves the cursor to row 1 and reports success; ShardingSphere's forward-only merged ResultSet cannot jump backward to the first row, so the method is final and throws SQLFeatureNotSupportedException. Row 1 may already have been consumed from the shard merge stream.","triggerScenarios":"Calling rs.first() — e.g. to fetch a single expected row — on a ResultSet from ShardingSphereDataSource instead of next().","commonSituations":"Single-row lookups written as if (rs.first()) { ... }; code migrated from Oracle/DB2 style; generic DAO helpers that call first() before reading columns.","solutions":["Use rs.next() to position on the first row — it is the supported forward move and returns false when empty.","For guaranteed-single-row queries, still check next() and optionally assert !rs.next() again.","If you need random access later, copy rows into a List while iterating.","Configure tools that call first() (report engines, mappers) to use next()-based iteration or give them a CachedRowSet."],"exampleFix":"// before\nif (rs.first()) { name = rs.getString(1); } // throws\n\n// after\nif (rs.next()) { name = rs.getString(1); }","handlingStrategy":"validation","validationCode":"if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) {\n    boolean hasRow = rs.next(); // use next() instead of first()\n}","typeGuard":null,"tryCatchPattern":"try {\n    if (rs.first()) { read(rs); }\n} catch (SQLFeatureNotSupportedException e) {\n    if (rs.next()) { read(rs); }\n}","preventionTips":["Write single-row reads with next(), the universally supported forward move.","In shared helpers, expose only next()-based accessors.","Watch for first()/last() in code migrated from Oracle-style tutorials."],"tags":["jdbc","resultset","cursor","first-row","single-row"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}