{"record":{"id":"0890b9971d4c4896","repo":"prestodb/presto","slug":"statement-is-closed","errorCode":null,"errorMessage":"Statement is closed","messagePattern":"Statement is closed","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java","lineNumber":657,"sourceCode":"            PrestoResultSet resultSet = currentResult.get();\n            if (resultSet != null) {\n                resultSet.partialCancel();\n            }\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    {","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java#L639-L675","documentation":"connection() is the shared liveness guard for PrestoStatement: when the WeakReference to the PrestoConnection has been cleared (statement closed), it throws this SQLException. Every checkOpen() call funnels through here, so any operation on a closed statement surfaces this error.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:657 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not use a Statement after close(); create a new one via Connection.createStatement","Check for premature closure in try-with-resources scoping (statement closed before results are consumed)","Catch SQLException in generic JDBC frameworks that may operate on closed statements"],"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"}