{"record":{"id":"cd575b387330345b","repo":"prestodb/presto","slug":"result-set-type-must-be-type-forward-only","errorCode":null,"errorMessage":"Result set type must be TYPE_FORWARD_ONLY","messagePattern":"Result set type must be TYPE_FORWARD_ONLY","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java","lineNumber":894,"sourceCode":"            throws SQLException\n    {\n        if (isClosed()) {\n            throw new SQLException(\"Connection is closed\");\n        }\n    }\n\n    private void initializeQueryInterceptors()\n    {\n        for (QueryInterceptor interceptor : this.queryInterceptorInstances) {\n            interceptor.init(this.sessionProperties);\n        }\n    }\n\n    private static void checkResultSet(int resultSetType, int resultSetConcurrency)\n            throws SQLFeatureNotSupportedException\n    {\n        if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {\n            throw new SQLFeatureNotSupportedException(\"Result set type must be TYPE_FORWARD_ONLY\");\n        }\n        if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {\n            throw new SQLFeatureNotSupportedException(\"Result set concurrency must be CONCUR_READ_ONLY\");\n        }\n    }\n\n    private static void checkHoldability(int resultSetHoldability)\n            throws SQLFeatureNotSupportedException\n    {\n        if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {\n            throw new SQLFeatureNotSupportedException(\"Result set holdability must be HOLD_CURSORS_OVER_COMMIT\");\n        }\n    }\n\n    private static String getIsolationLevel(int level)\n            throws SQLException\n    {\n        switch (level) {","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java#L876-L912","documentation":"PrestoConnection.checkResultSet() throws SQLFeatureNotSupportedException when createStatement/prepareStatement is called with a resultSetType other than ResultSet.TYPE_FORWARD_ONLY. Presto query results are streamed over HTTP in one direction, so scrollable (TYPE_SCROLL_INSENSITIVE/TYPE_SCROLL_SENSITIVE) result sets are genuinely unsupported, not just unimplemented. The check runs before any statement is created.","triggerScenarios":"createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ...), createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ...), prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ...) or any call passing a non-forward-only type.","commonSituations":"Shared DAO/utility code written for MySQL/Oracle that requests scrollable cursors by default; ORM or reporting frameworks configured with scrollable result sets; copy-pasted connection code from another driver's samples.","solutions":["Use createStatement() / prepareStatement(sql) with defaults (TYPE_FORWARD_ONLY, CONCUR_READ_ONLY)","Explicitly pass ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY","If random access is needed, buffer rows into your own list instead of scrolling the ResultSet"],"exampleFix":"// before\nStatement stmt = conn.createStatement(\n    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);\n// after\nStatement stmt = conn.createStatement(\n    ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);","handlingStrategy":"validation","validationCode":"int type = ResultSet.TYPE_SCROLL_INSENSITIVE; // value read from config\nif (type != ResultSet.TYPE_FORWARD_ONLY) {\n    type = ResultSet.TYPE_FORWARD_ONLY; // coerce before calling driver\n}","typeGuard":null,"tryCatchPattern":"try {\n    stmt = conn.createStatement(type, ResultSet.CONCUR_READ_ONLY);\n} catch (SQLFeatureNotSupportedException e) {\n    stmt = conn.createStatement(); // fallback to defaults\n}","preventionTips":["Always use the no-arg createStatement()/prepareStatement(sql) with Presto","Centralize statement creation in one helper that pins forward-only/read-only","Do not port scrollable-cursor settings from other JDBC drivers"],"tags":["jdbc","unsupported-feature","resultset","presto"],"backgroundTag":"sqlfeaturenotsupported","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"}