{"record":{"id":"5483372715897882","repo":"prestodb/presto","slug":"prepared-sql-statement-is-not-a-query","errorCode":null,"errorMessage":"Prepared SQL statement is not a query: ","messagePattern":"Prepared SQL statement is not a query: ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java","lineNumber":110,"sourceCode":"    @Override\n    public void close()\n            throws SQLException\n    {\n        if (isClosed) {\n            return;\n        }\n        super.execute(format(\"DEALLOCATE PREPARE %s\", statementName));\n        super.close();\n        isClosed = true;\n    }\n\n    @Override\n    public ResultSet executeQuery()\n            throws SQLException\n    {\n        requireNonBatchStatement();\n        if (!super.execute(getExecuteSql(statementName, toValues(parameters)))) {\n            throw new SQLException(\"Prepared SQL statement is not a query: \" + originalSql);\n        }\n        return getResultSet();\n    }\n\n    @Override\n    public int executeUpdate()\n            throws SQLException\n    {\n        requireNonBatchStatement();\n        return Ints.saturatedCast(executeLargeUpdate());\n    }\n\n    @Override\n    public long executeLargeUpdate()\n            throws SQLException\n    {\n        requireNonBatchStatement();\n        if (super.execute(getExecuteSql(statementName, toValues(parameters)))) {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java#L92-L128","documentation":"executeQuery on a PrestoPreparedStatement runs 'EXECUTE <statementName>' against the server; if super.execute returns true, the server produced a result set, otherwise the prepared statement was an UPDATE/DDL/other non-query statement. This SQLException signals that the caller used executeQuery on a prepared statement that does not return rows.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use executeUpdate()/executeLargeUpdate() instead when the prepared statement is an INSERT/UPDATE/DELETE or DDL","Inspect the original SQL to confirm whether it should return rows (e.g. a SELECT)","Wrap in try-catch if the statement type is determined dynamically at runtime"],"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"}