Updated on 2023-08-31 GMT+08:00

Debugging the Sample Application in Linux

Hive JDBC applications can run in a Linux environment where a Hive client is installed. After the application code is compiled and packaged, you can upload the JAR file to the prepared Linux environment.

Prerequisites

  • The Hive client has been installed.
  • If the host where the client is installed is not a node in the cluster, the mapping between the host name and the IP address must be set in the hosts file on the node where the client is deployed. The host names and IP addresses must be mapped one on one.

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 running directory, for example, /opt/jdbc_example. Save the JAR packages whose names contain -with-dependencies generated in 1 in the target directory to this directory. Create the src/main/resources subdirectory in the directory and copy all files in the hive-jdbc-example\src\main\resources directory obtained in Configuring and Importing the JDBC/HCatalog Sample Project to the src/main/resources directory.
    2. Run the JAR package.

      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!