From e8d4bd6c6dc61ffc0b448ed9f0b450d89215b36d Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 09:25:50 -0700 Subject: [PATCH 1/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index e0e76042f..00a5c38fe 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -1,4 +1,4 @@ -name: Examples +name: Run Examples on: workflow_dispatch: @@ -42,11 +42,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 name: Run Examples + needs: compile steps: - name: Run Docker run: | - docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret\ - -p 8123:8123 clickhouse/clickhouse-server + docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server cd examples/jdbc - mvn - mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" \ No newline at end of file + mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" From c13a80a70292f15329559c8a1eef6bf17e5fdb42 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 09:52:45 -0700 Subject: [PATCH 2/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 00a5c38fe..8505de08d 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -2,11 +2,7 @@ name: Run Examples on: workflow_dispatch: - inputs: - version: - description: "Release version" - required: true - + concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }} cancel-in-progress: true @@ -32,18 +28,33 @@ jobs: 8 21 cache: "maven" + - name: Cache Artifacts + id: cache-ch-artifats + uses: actions/cache@v4 + with: + path: ~/.m2/repository/com/clickhouse/** + key: ${{ github.run_id }}-ch-artifacts - name: Build and install libraries run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -Dj8 -DskipITs install - name: Compile examples run: | cd examples/jdbc mvn clean compile + echo "Run Id ${{ github.run_id }}" run-examples: runs-on: ubuntu-latest timeout-minutes: 15 name: Run Examples needs: compile steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Restore cached Primes + id: cache-primes-restore + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository/com/clickhouse/ + key: ${{ github.run_id }}-ch-artifacts - name: Run Docker run: | docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server From 2b05c1f97efbe527f0f4f3f66941ea7a3f8ff917 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 10:27:49 -0700 Subject: [PATCH 3/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 8505de08d..b35d7ab9e 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -28,11 +28,11 @@ jobs: 8 21 cache: "maven" - - name: Cache Artifacts - id: cache-ch-artifats - uses: actions/cache@v4 + - name: Save Repo Artifacts + id: save-repo-artifacts + uses: actions/cache/save@v4 with: - path: ~/.m2/repository/com/clickhouse/** + path: ~/.m2/repository/com/clickhouse key: ${{ github.run_id }}-ch-artifacts - name: Build and install libraries run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -Dj8 -DskipITs install @@ -49,11 +49,11 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - - name: Restore cached Primes - id: cache-primes-restore + - name: Restore Repo Artifacts + id: restore-repo-artifacts uses: actions/cache/restore@v4 with: - path: ~/.m2/repository/com/clickhouse/ + path: ~/.m2/repository/com/clickhouse key: ${{ github.run_id }}-ch-artifacts - name: Run Docker run: | From 730ea443f5e9a0b9142e9097bedae7e8a26e8a54 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 10:33:54 -0700 Subject: [PATCH 4/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index b35d7ab9e..38b18f259 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -59,4 +59,5 @@ jobs: run: | docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server cd examples/jdbc + mvn --batch-mode --no-transfer-progress --show-version clean compile mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" From c2a4a6032aca6bd0caea74213c77d2654715f39a Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 10:43:00 -0700 Subject: [PATCH 5/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 38b18f259..5e172d047 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -55,9 +55,9 @@ jobs: with: path: ~/.m2/repository/com/clickhouse key: ${{ github.run_id }}-ch-artifacts - - name: Run Docker + - name: Run Examples run: | - docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server + docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server:24.8 cd examples/jdbc mvn --batch-mode --no-transfer-progress --show-version clean compile - mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" + mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DfailOnError=true From 2e121e6cfce1f2b58de06a0f5a3b31d6643c8c50 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 10:47:47 -0700 Subject: [PATCH 6/7] Update run_examples.yml --- .github/workflows/run_examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 5e172d047..54815761b 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -60,4 +60,4 @@ jobs: docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server:24.8 cd examples/jdbc mvn --batch-mode --no-transfer-progress --show-version clean compile - mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DfailOnError=true + mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DchPassword=secret -DfailOnError=true From c3c27bbf099719ca4a55b7c38efb1da7d0c20719 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Mon, 2 Jun 2025 10:52:39 -0700 Subject: [PATCH 7/7] Make example throw exception --- .../com/clickhouse/examples/jdbc/Basic.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java b/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java index ab3ce047c..65ad4cfda 100644 --- a/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java +++ b/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java @@ -21,7 +21,7 @@ public class Basic { private static final Logger log = LoggerFactory.getLogger(Basic.class); static final String TABLE_NAME = "jdbc_example_basic"; - public static void main(String[] args) { + public static void main(String[] args) throws Exception { String url = System.getProperty("chUrl", "jdbc:ch://localhost:8123"); // Set user and password if needed @@ -29,19 +29,15 @@ public static void main(String[] args) { properties.setProperty("user", System.getProperty("chUser", "default")); properties.setProperty("password", System.getProperty("chPassword", "")); - try { - createTable(url, properties); - insertDateWithPreparedStatement(url, properties); - printInsertedData(url, properties); + createTable(url, properties); + insertDateWithPreparedStatement(url, properties); + printInsertedData(url, properties); - //Customizing client settings - setClientSettings(properties); + //Customizing client settings + setClientSettings(properties); - //Using HikariCP with ClickHouseDataSource - usedPooledConnection(url, properties); - } catch (SQLException e) { - log.error("Error", e); - } + //Using HikariCP with ClickHouseDataSource + usedPooledConnection(url, properties); } static void createTable(String url, Properties properties) throws SQLException {