Skip to content

Commit 8a369b5

Browse files
committed
added test for DriverProperties.RESULTSET_AUTO_CLOSE
1 parent 65d956a commit 8a369b5

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/DriverProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public enum DriverProperties {
4646
/**
4747
* Enables closing result set before
4848
*/
49-
RESULTSET_AUTO_CLOSE("jdbc_resultset_auto_close", String.valueOf(Boolean.FALSE)),
49+
RESULTSET_AUTO_CLOSE("jdbc_resultset_auto_close", String.valueOf(Boolean.TRUE)),
5050

5151
/**
5252
* Enables using server property `max_result_rows` ({@link ServerSettings#MAX_RESULT_ROWS} to limit number of rows returned by query.

jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class StatementImpl implements Statement, JdbcV2Wrapper {
4343
protected volatile String lastQueryId;
4444
private long maxRows;
4545
private boolean closeOnCompletion;
46-
private boolean resultSetAutoClose;
46+
private final boolean resultSetAutoClose;
4747
private int maxFieldSize;
4848
private boolean escapeProcessingEnabled;
4949

jdbc-v2/src/test/java/com/clickhouse/jdbc/StatementTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,8 @@ public void testWithIPs() throws Exception {
511511
}
512512
}
513513

514-
@Test
514+
@Test(groups = {"integration"})
515515
public void testConnectionExhaustion() throws Exception {
516-
517516
int maxNumConnections = 3;
518517
Properties properties = new Properties();
519518
properties.put(ClientConfigProperties.HTTP_MAX_OPEN_CONNECTIONS.getKey(), "" + maxNumConnections);
@@ -526,6 +525,20 @@ public void testConnectionExhaustion() throws Exception {
526525
}
527526
}
528527
}
528+
529+
properties.put(DriverProperties.RESULTSET_AUTO_CLOSE.getKey(), "false");
530+
try (Connection conn = getJdbcConnection(properties)) {
531+
try (Statement stmt = conn.createStatement()) {
532+
try {
533+
for (int i = 0; i < maxNumConnections * 2; i++) {
534+
stmt.executeQuery("SELECT number FROM system.numbers LIMIT 100");
535+
}
536+
fail("Exception expected");
537+
} catch (SQLException e) {
538+
// ignore
539+
}
540+
}
541+
}
529542
}
530543

531544
@Test(groups = {"integration"})

0 commit comments

Comments
 (0)