{"record":{"id":"0e2695b07367c990","repo":"prestodb/presto","slug":"first","errorCode":null,"errorMessage":"first","messagePattern":"first","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java","lineNumber":657,"sourceCode":"    @Override\n    public void beforeFirst()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"beforeFirst\");\n    }\n\n    @Override\n    public void afterLast()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"afterLast\");\n    }\n\n    @Override\n    public boolean first()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"first\");\n    }\n\n    @Override\n    public boolean last()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"last\");\n    }\n\n    @Override\n    public int getRow()\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"getRow\");\n    }\n\n    @Override\n    public boolean absolute(int row)","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java#L639-L675","documentation":"PrestoResultSet throws SQLFeatureNotSupportedException(\"first\") because the driver only supports forward-only, read-once iteration over Presto query results. There is no row buffer, so jumping to the first row after iteration has started is impossible.","triggerScenarios":"Calling ResultSet.first() on a PrestoResultSet, e.g. after using next() or when the caller expects a scrollable result set.","commonSituations":"Code that checks rs.first() to test for an empty result set, or legacy JDBC code written for MySQL/Oracle scrollable result sets being reused against Presto.","solutions":["Use rs.next() instead of rs.first() to test whether any rows exist","Re-execute the query when you need to return to the first row","Limit the query (LIMIT 1) and execute it again if only the first row is needed","Buffer rows in a local collection to allow random access"],"exampleFix":"// before\nif (rs.first()) { handle(rs); }\n// after\nif (rs.next()) { handle(rs); }","handlingStrategy":"try-catch","validationCode":"DatabaseMetaData md = conn.getMetaData();\nboolean scrollable = md.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); // false for Presto","typeGuard":null,"tryCatchPattern":"try { rs.first(); } catch (SQLFeatureNotSupportedException e) { /* use rs.next() to check for rows */ }","preventionTips":["Use rs.next() to test for a non-empty result set","Re-run the query when the first row must be revisited","Avoid scrollable-result-set idioms when targeting Presto"],"tags":["jdbc","unsupported-operation","forward-only-resultset"],"backgroundTag":"jdbc-resultset-navigation-unsupported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}