Skip to content

Commit 0e78363

Browse files
committed
made async operation when timeout is set to non zero
1 parent 7ec63e6 commit 0e78363

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ protected ResultSetImpl executeQueryImpl(String sql, QuerySettings settings) thr
174174
if (queryTimeout == 0) {
175175
response = connection.getClient().query(lastStatementSql, mergedSettings).get();
176176
} else {
177-
response = connection.getClient().query(lastStatementSql, mergedSettings).get(queryTimeout, TimeUnit.SECONDS);
177+
// we need to perform async operation to support timeout.
178+
response = connection.getClient().query(lastStatementSql, mergedSettings
179+
.setOption(ClientConfigProperties.ASYNC_OPERATIONS.getKey(), true))
180+
.get(queryTimeout, TimeUnit.SECONDS);
178181
}
179182

180183
if (response.getFormat().isText()) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,7 @@ void testSelectFromArray() throws Exception {
570570
@Test(groups = {"integration"})
571571
void testExecuteQueryTimeout() throws Exception {
572572
final String sql = "SELECT sum(reinterpretAsUInt64(MD5(toString(number)))) FROM system.numbers LIMIT 1000000";
573-
Properties config = new Properties();
574-
config.setProperty(ClientConfigProperties.ASYNC_OPERATIONS.getKey(), "true");
575-
try (Connection conn = getJdbcConnection(config);
573+
try (Connection conn = getJdbcConnection();
576574
PreparedStatement stmt = conn.prepareStatement(sql)) {
577575
stmt.setQueryTimeout(1);
578576
assertThrows(SQLException.class, stmt::executeQuery);

0 commit comments

Comments
 (0)