Commissioning the ClickHouse Application in the Local Windows Environment (MRS 3.3.0 and Later Versions)
Switching the JDK Version Used in IDEA (MRS 3.6.0-LTS and Later Versions)
Before commissioning a program, you need to check the JDK version (JDK 8 is used by default in IDEA) and change it as required.
The following operations use JDK 17 as an example. The operations for JDK 8 are similar.
- On the IDEA, choose File > Project Structure. Figure 1 Choosing Project Structure
- Choose Platform Settings > SDKs > + > Add JDK.... Figure 2 Add JDK
- Select the downloaded JDK 17 version and choose OK > Apply > OK. Figure 3 Adding a JDK version
- Choose Project. On the displayed page, select the JDK 17 from the drop-down list of SDK. Figure 4 Selecting a JDK version
- In the pom.xml file of the secondary development sample project, change the values of source and target in the maven-compiler-plugin parameter to the actual JDK version, for example, 17. If other JDK versions are used, change the values based on the site requirements. Figure 5 Modifying parameters
Compiling and Runing the Application
You can run the application in the Windows environment after you finish writing application code. If the local and cluster service planes can communicate with each other, you can perform the commissioning on the local host.
Procedure
- Click Reload All Maven Projects in the Maven window on the right of the IDEA to import the Maven project dependency. Figure 6 Reloading projects
- Copy the clickhouse-example.properties path on the IDEA page. Right-click clickhouse-example.properties and choose Copy Path/Reference > Absolute Path from the shortcut menu.
Skip this step if you are commissioning the transaction sample project.
Figure 7 Copying absolute path of the configuration file
- In Demo.java, replace the path of proPath in the getProperties() method with the path clickhouse-example.properties. Figure 8 Replacing the path
- In ClickhouseJDBCHaDemo.java, replace the path of proPath in the initConnection() method with clickhouse-example.properties.
Skip this step if you are commissioning the transaction sample project.
Figure 9 Replacing the path
- If SSL is disabled in the clickhouse-example.properties configuration file, replace the proPath path in the initConnection() method with the clickhouse-example.properties path in NativeJDBCHaDemo.java. Figure 10 Replacing the path
- Compile the application.
- Select Maven > clickhouse-examples > Lifecycle > clean and double-click clean to run the clean command of Maven.
- Select Maven > clickhouse-examples > Lifecycle > compile and double-click compile to run the compile command of Maven.
Figure 11 Maven commands clean and compile
- Click Run'Demo.main()' to run the application. Figure 12 Running the program
Viewing Commissioning Results
After a ClickHouse application finishes running, you can use one of the following methods to view the running result:
- View the command output.
- View the clickhouse-example.log file in the logs directory to obtain the application running status.
After the complete sample of the clickhouse-examples finishes running, the following information is displayed on the console:
2023-09-19 16:20:48,344 | INFO | main | loadBalancerIPList is 192.168.5.132, loadBalancerHttpPort is 21422, user is ck_user, clusterName is default_cluster, isSec is true, password is Admin12!. | com.huawei.clickhouse.examples.Demo.main(Demo.java:42)
2023-09-19 16:20:48,350 | INFO | main | ckLbServerList current member is 0, ClickhouseBalancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Demo.getCkLbServerList(Demo.java:110)
2023-09-19 16:20:48,436 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:50,781 | INFO | main | Execute query:drop table if exists testdb.testtb on cluster default_cluster no delay | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:51,504 | INFO | main | Execute time is 723 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:51,511 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:51,897 | INFO | main | Execute query:drop table if exists testdb.testtb_all on cluster default_cluster no delay | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:52,421 | INFO | main | Execute time is 524 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:52,422 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:52,946 | INFO | main | Execute query:create database if not exists testdb on cluster default_cluster | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:53,405 | INFO | main | Execute time is 458 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:53,406 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:53,757 | INFO | main | Execute query:create table testdb.testtb on cluster default_cluster (name String, age UInt8, date Date)engine=ReplicatedMergeTree('/clickhouse/tables/{shard}/testdb.testtb','{replica}') partition by toYYYYMM(date) order by age | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:54,243 | INFO | main | Execute time is 485 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:54,244 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:54,640 | INFO | main | Execute query:create table testdb.testtb_all on cluster default_cluster as testdb.testtb ENGINE = Distributed(default_cluster,testdb,testtb, rand()); | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:55,175 | INFO | main | Execute time is 535 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:55,175 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.insertData(Util.java:143)
2023-09-19 16:20:58,868 | INFO | main | Insert batch time is 503 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:160)
2023-09-19 16:21:01,015 | INFO | main | Insert batch time is 631 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:160)
2023-09-19 16:21:02,521 | INFO | main | Inert all batch time is 4163 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:164)
2023-09-19 16:21:02,522 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:21:03,051 | INFO | main | Execute query:select * from testdb.testtb_all order by age limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:21:03,430 | INFO | main | Execute time is 379 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:21:03,433 | INFO | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:21:03,760 | INFO | main | Execute query:select toYYYYMM(date),count(1) from testdb.testtb_all group by toYYYYMM(date) order by count(1) DESC limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:21:04,361 | INFO | main | Execute time is 600 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:21:04,362 | INFO | main | name age date | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,362 | INFO | main | huawei_9 12 2021-04-20 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,362 | INFO | main | huawei_17 15 2021-05-23 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_5 24 2021-04-15 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_13 39 2020-07-04 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_3 49 2021-06-27 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_15 50 2020-06-26 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_11 53 2020-08-14 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_12 56 2021-12-19 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_19 57 2021-10-31 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | huawei_0 57 2020-03-01 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO | main | toYYYYMM(date) count() | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202105 3 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202110 2 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202104 2 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202008 2 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202007 2 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202106 2 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202012 1 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202109 1 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO | main | 202003 1 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,365 | INFO | main | 202011 1 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:05,044 | INFO | main | Name is: huawei_9, age is: 12 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,044 | INFO | main | Name is: huawei_17, age is: 15 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_5, age is: 24 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_13, age is: 39 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_3, age is: 49 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_15, age is: 50 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_11, age is: 53 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_12, age is: 56 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO | main | Name is: huawei_19, age is: 57 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,046 | INFO | main | Name is: huawei_0, age is: 57 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
Process finished with exit code 0 What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot