Skip to content

Commit 202b0a4

Browse files
author
Paultagoras
committed
Update StatementTest.java
1 parent af70e85 commit 202b0a4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.clickhouse.client.api.Client;
44
import com.clickhouse.client.api.ClientConfigProperties;
55
import com.clickhouse.client.api.query.GenericRecord;
6+
import com.clickhouse.client.api.query.QuerySettings;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
69
import org.testng.Assert;
710
import org.testng.annotations.Test;
811

@@ -18,6 +21,7 @@
1821
import java.util.Arrays;
1922
import java.util.List;
2023
import java.util.Properties;
24+
import java.util.UUID;
2125
import java.util.concurrent.TimeUnit;
2226

2327
import static org.testng.Assert.*;
@@ -29,6 +33,8 @@
2933

3034

3135
public class StatementTest extends JdbcIntegrationTest {
36+
private static final Logger log = LoggerFactory.getLogger(StatementTest.class);
37+
3238
@Test(groups = { "integration" })
3339
public void testExecuteQuerySimpleNumbers() throws Exception {
3440
try (Connection conn = getJdbcConnection()) {
@@ -471,4 +477,28 @@ public void testConnectionExhaustion() throws Exception {
471477
}
472478
}
473479
}
480+
481+
@Test(groups = { "integration" })
482+
public void testConcurrentCancel() throws Exception {
483+
try (Connection conn = getJdbcConnection()) {
484+
try (StatementImpl stmt = (StatementImpl) conn.createStatement()) {
485+
stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000");
486+
stmt.cancel();
487+
}
488+
try (StatementImpl stmt = (StatementImpl) conn.createStatement()) {
489+
new Thread(() -> {
490+
try {
491+
ResultSet rs = stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000");
492+
rs.next();
493+
log.info(rs.getObject(1).toString());
494+
} catch (SQLException e) {
495+
log.error("Error in thread", e);
496+
}
497+
}).start();
498+
499+
Thread.sleep(1000);
500+
stmt.cancel();
501+
}
502+
}
503+
}
474504
}

0 commit comments

Comments
 (0)