Configuring and Importing the JDBC/HCatalog Sample Project
Scenario
To run the JDBC API example codes of the Hive component of MRS, perform the following operations.
- The following uses the development of an application for connecting the Hive service in JDBC/HCatalog mode on Windows as an example.
- The HCatalog sample can run only on Linux nodes.
Procedure
- Obtain the sample project folder hive-jdbc-example or hcatalog-example in the src\hive-examples directory where the sample code is decompressed. For details, see Obtaining the MRS Application Development Sample Project.
- For the hive-jdbc-example sample project, place the following files in the hive-jdbc-example\src\main\resources directory:
- Authentication files user.keytab and krb5.conf obtained in User Information for Cluster Authentication.
- Configuration files core-site.xml and hiveclient.properties obtained in .
- Go to the client decompression path FusionInsight_Cluster_1_Services_ClientConfig_ConfigFiles\Hive\config and manually import the core-site.xml and hiveclient.properties files to the hive-jdbc-example\src\main\resources directory of the sample project.
- Import the example project to the IntelliJ IDEA development environment.
- On the IntelliJ IDEA menu bar, choose File>Open.... The Open File or Project window is displayed.
- In the displayed window, select the folder hive-jdbc-example, and click OK. On Windows, the path cannot contain any space.
- Set the IntelliJ IDEA text file coding format to prevent garbled characters.
- On the IntelliJ IDEA menu bar, choose File>Settings.
The Settings window is displayed.
- In the navigating tree on the left, choose Editor>File Encodings. In theProject Encoding area and Global Encodingarea, set the value toUTF-8, and clickApplyandOK, as shown inFigure 1.
- On the IntelliJ IDEA menu bar, choose File>Settings.
- Set the JDK of the project.
- On the IntelliJ IDEA menu bar, choose File>Settings.... The Settings window is displayed.
- Choose Build, Execution, Deployment > Compiler > Java Compiler, select 8 from the Project bytecode version drop-down list box. Change the value of Target bytecode version to 8 for hive-jdbc-example.

- ClickApplyandOK.
- On the IntelliJ IDEA menu bar, choose File>Project Structure.... The Project Structure window is displayed.
- Select SDKs, click the plus sign (+), and select JDK.

- On the Select Home Directory for JDK page that is displayed, select the JDK directory and click OK.
- After selecting the JDK, click Apply.
- Select Project, select the JDK added in SDKs from the Project SDK drop-down list box, and select 8 - Lambdas, type annotations etc. from the Project language level drop-down list box.

- ClickApply.
- Choose Modules. On the Source page, change the value of Language level to 8 - Lambdas, type annotations etc.

On the Dependencies page, change the value of Module SDK to the JDK added in SDKs.

- ClickApplyandOK.
- Configure Maven.
- Add the configuration information such as the address of the open-source image repository to the setting.xml configuration file of the local Maven by referring to Configuring Huawei Open-Source Mirrors.
- On the IntelliJ IDEA page, select File > Settings > Build, Execution, Deployment > Build Tools > Maven, select Override next to User settings file, and change the value of User settings file to the directory where the settings.xml file is stored. Ensure that the directory is <Local Maven installation directory>\conf\settings.xml.
Figure 2 Directory for storing the settings.xml file
- Click the drop-down list next to Maven home directory and select the Maven installation directory.
- Click Apply, and then click OK.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
