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 application code is compiled and packaged, you can upload the JAR file to the prepared Linux environment.

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 access the terminal. Run the mvn clean package command to perform compilation.

    If "BUILD SUCCESS" is displayed, the compilation is successful. A JAR file containing the -with-dependencies field is 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. Replace it with the actual one.

    3. View the HiveQL query results of the sample code in the command line interface. If the following information is displayed, the execution is successful.
      Create table success!
      _c0
      0
      Delete table success!