Running JDBC and Viewing Results
Running JDBC in CLI Mode
- On the right of the IntelliJ IDEA home page, click Maven Projects. On the Maven Projects page, choose Project name > Lifecycle and run the clean and compile scripts.
Figure 1 Maven Projects page
- In the lower left corner of the IDEA page, click Terminal to access the terminal. Run the mvn clean package command to compile the package.
If BUILD SUCCESS is displayed, the compilation is successful, as shown in the following figure. A JAR file containing the -with-dependencies field is generated in the target directory of the sample project.
- Create a directory on Windows or Linux as the running directory, for example, D:\jdbc_example (Windows) or /opt/jdbc_example (Linux). Place the JAR file whose name contains -with-dependencies in the target directory generated in 2 to this directory. Create the src/main/resources subdirectory in the directory. Copy all files in the resources directory of the jdbc-examples project to the resources directory.
- In Windows, run the following command:
cd /d d:\jdbc_example
java -jar hive-jdbc-example-1.0-SNAPSHOT-jar-with-dependencies.jar
In Linux, run the following command:
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 names are for reference only. The actual names may vary.
- In the CLI, view the HQL query results in the example codes.
The following information is displayed if the sample project is successful in Windows:
Create table success! _c0 0 Delete table success!
The following information is displayed if the sample project is successful in Linux:Create table success! _c0 0 Delete table success!
Running JDBC in IntelliJ IDEA Mode
- On the right of the IntelliJ IDEA home page, click Maven Projects. On the Maven Projects page, choose Project name > Lifecycle and run the clean and compile scripts.
Figure 2 Maven Projects page
- Right-click the JDBCExample class in the IntelliJ IDEA jdbc-examples project, and choose Run JDBCExample.main() from the shortcut menu. As shown in the following figure.
- In the IntelliJ IDEA output window, view the HQL query results in the example codes.
Create table success! _c0 0 Delete table success!
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot