Title: PreparedStatement.execute() returns True for DML/DDL queries · Issue #797 · apache/arrow-java · GitHub
Open Graph Title: PreparedStatement.execute() returns True for DML/DDL queries · Issue #797 · apache/arrow-java
X Title: PreparedStatement.execute() returns True for DML/DDL queries · Issue #797 · apache/arrow-java
Description: Describe the bug, including details regarding any error messages, version, and platform. In Apache Arrow Flight SQL Prepared Statement execution, result set generating queries should be executed via CommandPreparedStatementQuery and quer...
Open Graph Description: Describe the bug, including details regarding any error messages, version, and platform. In Apache Arrow Flight SQL Prepared Statement execution, result set generating queries should be executed vi...
X Description: Describe the bug, including details regarding any error messages, version, and platform. In Apache Arrow Flight SQL Prepared Statement execution, result set generating queries should be executed vi...
Opengraph URL: https://github.com/apache/arrow-java/issues/797
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PreparedStatement.execute() returns True for DML/DDL queries","articleBody":"### Describe the bug, including details regarding any error messages, version, and platform.\n\nIn Apache Arrow Flight SQL Prepared Statement execution, result set generating queries should be executed via `CommandPreparedStatementQuery` and queries that return only the number of affected rows should be executed via `CommandPreparedStatementUpdate`\n\nIn JDBC, `PreparedStatement.execute()` allows for running generic queries, including SELECT, DML and DDL. For DML/DDL, this method should return `False` and provide an update count, for SELECT it should return `True` and result set should be provided. \n\nThe cause of the issue is that the driver always follows the Arrow Flight SQL communications path for result set generating queries, meaning, the query is always executed via `CommandPreparedStatementQuery` and never via `CommandPreparedStatementUpdate` This means that the driver tries to execute DML/DDL as if they were SELECT statements, which can lead to incorrect return values of PreparedStatement.execute()\n\nCode snippet to reproduce:\n\n``` \n// connection is a previously established Connection instance to a Flight SQL server\nString insertPreparedStatementSingleRow = \"INSERT INTO my_table (name) VALUES (?)\";\ntry (PreparedStatement pstmt = connection.prepareStatement(insertPreparedStatementSingleRow)) {\n pstmt.setString(1, \"My name\");\n boolean hasResultSet = pstmt.execute();\n if (hasResultSet) {\n System.out.println(\"Unexpected: INSERT returned a ResultSet\");\n try (ResultSet rs = pstmt.getResultSet()) {\n // Handle unexpected ResultSet\n System.out.println(\"Unexpected ResultSet...\");\n }\n } else {\n // false = Update count available\n int updateCount = pstmt.getUpdateCount();\n System.out.println(\"Update count: \" + updateCount + \" row(s) affected\");\n }\n}\n```\n\nThis was tested with a Dremio Arrow Flight SQL server, but looking at the driver's code seems to be an issue that affects all servers.\n","author":{"url":"https://github.com/ennuite","@type":"Person","name":"ennuite"},"datePublished":"2025-07-15T16:41:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/797/arrow-java/issues/797"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb5a1d93-6e5c-43ca-345d-76d0e590f5ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B21A:1EDC:14F39E9:1E174C7:6A4FC276 |
| html-safe-nonce | 2b7fdc32dc6816781e05ba55ee452b5affd2dd19d948ad90d432bfdc5befdd3a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjFBOjFFREM6MTRGMzlFOToxRTE3NEM3OjZBNEZDMjc2IiwidmlzaXRvcl9pZCI6IjkxMjQyNDkzNTU5OTczOTc2MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b7568b8682b483fd1b3e2248a5e9afeeb32d11bfad2e3586caa5105ef4e05d8c |
| hovercard-subject-tag | issue:3232948741 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/arrow-java/797/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e903f2e54203f0120ce36e039e2d26463a29fd29b98216b150cd1e77167c9b96/apache/arrow-java/issues/797 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e903f2e54203f0120ce36e039e2d26463a29fd29b98216b150cd1e77167c9b96/apache/arrow-java/issues/797 |
| og:image:alt | Describe the bug, including details regarding any error messages, version, and platform. In Apache Arrow Flight SQL Prepared Statement execution, result set generating queries should be executed vi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ennuite |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d8f8209b188a80e19a6957836ab9229715797be5db1a04163963c674ccc33f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/arrow-java git https://github.com/apache/arrow-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 893682219 |
| octolytics-dimension-repository_nwo | apache/arrow-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 893682219 |
| octolytics-dimension-repository_network_root_nwo | apache/arrow-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ea848e83cf3bf3613dd7b13d52965a684fd23ec5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width