Updated on 2024-04-29 GMT+08:00

Configuring and Importing a Sample Project

Background Information

Obtain the ClickHouse development sample project and import the project to IntelliJ IDEA to learn the sample project.

Scenario

ClickHouse provides sample projects for multiple scenarios to help you quickly learn ClickHouse projects.

Procedure

  1. In the application development environment, import the sample project to the IntelliJ IDEA development environment.

    1. On the IDEA page, choose File > New > Project from Existing Sources.

    2. In the displayed Select File or Directory to Import dialog box, select the pom.xml file in the clickhouse-examples folder and click OK.
    3. Confirm subsequent configurations and click Next. If there is no special requirement, use the default values.
    4. Select the recommended JDK version and click Finish.

  2. After the project is imported, modify the clickhouse-example.properties file in the conf directory of the sample project based on the actual environment information.

    ipList=
    sslUsed=false
    httpPort=8123
    httpsPort=
    CLICKHOUSE_SECURITY_ENABLED=false
    user=default
    password=
    clusterName=default_cluster
    databaseName=testdb
    tableName=testtb
    batchRows=10000
    batchNum=10
    clickhouse_dataSource_ip_list=ip:8123,ip:8123
    native_dataSource_ip_list=ip:9000,ip:9000
    Table 1 Configuration parameters

    Parameter

    Default Value

    Description

    iPList

    -

    Cluster access address list of the clickhouse node. This parameter is mandatory.

    Log in to the CloudTable console, click the cluster name to go to the cluster details page, and obtain the cluster access address.

    Use commas (,) to separate multiple addresses, for example, cloudtable-wlr-cli-server-1-1-2lIWzDO9.mycloudtable.com,cloudtable-wlr-cli-server-2-1-iqVWp2Mo.mycloudtable.com.

    sslUsed

    false

    Whether to enable SSL encryption. The default value is false.

    httpPort

    8123

    HTTP port number for connection. The value is 8123.

    httpsPort

    -

    HTTPS port used for connection. The value is 8443.

    CLICKHOUSE_SECURITY_ENABLED

    false

    Whether to enable the security mode. Set this parameter to false for a cluster in normal mode.

    user

    default

    Development user.

    password

    -

    Password of the development user.

    clusterName

    default_cluster

    ClickHouse logical cluster name. Retain the default value.

    databaseName

    testdb

    Name of the database to be created in the sample code project. You can change the database name based on the site requirements.

    tableName

    testtb

    Name of the table to be created in the sample code project. You can change the table name based on the site requirements.

    batchRows

    10000

    Number of data records written in a batch.

    batchNum

    10

    Total number of batches in which data is written.

    clickhouse_dataSource_ip_list

    -

    List of IP addresses and HTTP ports of the ClickHouse node, for example, cloudtable-wlr-cli-server-1-1-2lIWzDO9.mycloudtable.com:8123,cloudtable-wlr-cli-server-2-1-iqVWp2Mo.mycloudtable.com:8123.

    native_dataSource_ip_list

    -

    List of IP addresses and TCP ports of the ClickHouse node, for example, cloudtable-wlr-cli-server-1-1-2lIWzDO9.mycloudtable.com:9000,cloudtable-wlr-cli-server-2-1-iqVWp2Mo.mycloudtable.com:9000.