Updated on 2026-08-27 GMT+08:00

Debugging a Sample Hive JDBC Application in a Linux Environment

Hive JDBC applications can run in a Linux environment. After the program code has been developed, you can upload the JAR file to the prepared Linux runtime environment for execution.

Prerequisites

When the host running the Hive JDBC application is not a node in the cluster, you need to configure the mapping between the host names and IP addresses of the MRS cluster nodes in the hosts file of that host, ensuring a one-to-one correspondence between host names and IP addresses.

Procedure

  1. Compile the JDBC sample program.

    Click Terminal in the lower left corner of the IDEA page to open the terminal and run the mvn clean package command to compile.

    When the output displays "BUILD SUCCESS", the compilation is successful. After a successful compilation, a JAR file containing the -with-dependencies suffix will be generated in the target directory of the sample project.

  2. Run the JDBC sample program.

    1. Create a directory on Linux as the runtime directory, for example, /opt/jdbc_example. Place the JAR file with the -with-dependencies suffix in its name from the target directory generated in 1 into this path. Then, create a subdirectory src/main/resources under this directory, and copy all files from the obtained hive-jdbc-example\src\main\resources directory into the resources folder.
    2. Run the JAR file.

      chmod +x /opt/jdbc_example -R

      cd /opt/jdbc_example

      java -jar hive-jdbc-example-1.0-SNAPSHOT-jar-with-dependencies.jar

      The preceding JAR file name is for reference only. The actual name depends on the generated output.

    3. View the query results of the HiveQL in the sample code from the CLI. A successful run will display the following information:
      Create table success!
      _c0
      0
      Delete table success!