Skip to content

Commit

Permalink
Merge pull request #14349: [BEAM-12044] JdbcIO read: always force aut…
Browse files Browse the repository at this point in the history
…ocommit to false
  • Loading branch information
aromanenko-dev authored Mar 27, 2021
2 parents 776bf54 + a62fe3c commit 1f73a04
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,10 @@ public void processElement(ProcessContext context) throws Exception {
if (connection == null) {
connection = dataSource.getConnection();
}
// PostgreSQL requires autocommit to be disabled to enable cursor streaming
// see https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
LOG.info("Autocommit has been disabled");
connection.setAutoCommit(false);
try (PreparedStatement statement =
connection.prepareStatement(
query.get(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
Expand Down

0 comments on commit 1f73a04

Please sign in to comment.