Skip to content

Commit

Permalink
[BEAM-12044] JdbcIO read: always force autocommit to false
Browse files Browse the repository at this point in the history
  • Loading branch information
turb committed Mar 26, 2021
1 parent e30c349 commit a62fe3c
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 a62fe3c

Please sign in to comment.