Skip to content

Commit

Permalink
IGNITE-24074 Fix createStatement() throws when tx aware queries enabl…
Browse files Browse the repository at this point in the history
…ed (#11765)
  • Loading branch information
nizhikov authored Dec 22, 2024
1 parent 98f49d4 commit e04be8b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;
import java.util.List;
import org.apache.ignite.calcite.CalciteQueryEngineConfiguration;
Expand Down Expand Up @@ -292,4 +293,25 @@ public void testCloseConnectionWithoutCommit() throws Exception {
assertTrue(rs0.isClosed());
assertTrue(rs1.isClosed());
}

/** */
@Test
public void testCreateStatementOnDefaults() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
conn.setAutoCommit(false);

try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("SELECT 1")) {
assertEquals(1, F.size(grid().context().cache().context().tm().activeTransactions()));

try (Statement stmt2 = conn.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY)) {
try (ResultSet rs2 = stmt.executeQuery("SELECT 1")) {
assertEquals(1, F.size(grid().context().cache().context().tm().activeTransactions()));
}
}
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ void addBatch(String sql, List<Object> args) throws SQLException {

/** {@inheritDoc} */
@Override public Statement createStatement() throws SQLException {
return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, holdability);
}

/** {@inheritDoc} */
@Override public Statement createStatement(int resSetType, int resSetConcurrency) throws SQLException {
return createStatement(resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT);
return createStatement(resSetType, resSetConcurrency, holdability);
}

/** {@inheritDoc} */
Expand Down

0 comments on commit e04be8b

Please sign in to comment.