{"record":{"id":"8e528897f357307e","repo":"prestodb/presto","slug":"connection-is-closed-8e5288","errorCode":null,"errorMessage":"Connection is closed","messagePattern":"Connection is closed","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java","lineNumber":660,"sourceCode":"            }\n        }\n    }\n\n    protected final void checkOpen()\n            throws SQLException\n    {\n        connection();\n    }\n\n    protected final PrestoConnection connection()\n            throws SQLException\n    {\n        PrestoConnection connection = this.connection.get();\n        if (connection == null) {\n            throw new SQLException(\"Statement is closed\");\n        }\n        if (connection.isClosed()) {\n            throw new SQLException(\"Connection is closed\");\n        }\n        return connection;\n    }\n\n    private void closeResultSet()\n            throws SQLException\n    {\n        ResultSet resultSet = currentResult.getAndSet(null);\n        if (resultSet != null) {\n            resultSet.close();\n        }\n    }\n\n    private static boolean validFetchDirection(int direction)\n    {\n        return (direction == ResultSet.FETCH_FORWARD) ||\n                (direction == ResultSet.FETCH_REVERSE) ||\n                (direction == ResultSet.FETCH_UNKNOWN);","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java#L642-L678","documentation":"In connection(), after the statement's connection reference is found non-null, connection.isClosed() is checked: if the owning PrestoConnection has been closed this SQLException is thrown. It means the statement is being used after its parent connection was closed, so all further statement operations fail.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:660 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep the Connection open while its Statements/ResultSets are in use","Obtain a new connection and statement after the old connection was closed","Fix try-with-resources ordering so the connection outlives statement usage"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}