Preparing the Impala JDBC Client
To run the JDBC API sample code of Impala, you need to perform the following operations.
The following example develops an application that uses JDBC to connect to Impala in the Windows environment.
Procedure
- Obtain the Impala sample project by referring to Obtaining the MRS Application Development Sample Project.
- In the root directory of the Impala sample project, run the mvn install command to perform compilation.
- In the root directory of the Impala sample project, run the mvn eclipse:eclipse command to create an Eclipse project.
- In the application development environment, import the sample project to the Eclipse development environment.
- Choose File > Import > General > Existing Projects into Workspace > Next > Browse.
The Browse Folder dialog box is displayed.
- Select the impala-examples folder. On Windows, the folder path cannot contain any space.
Click Finish.
After successful import, the JDBCExample class in com.huawei.bigdata.impala.example is the JDBC API sample code.
- Choose File > Import > General > Existing Projects into Workspace > Next > Browse.
- Set an Eclipse text file encoding format to prevent garbled characters.
- On the Eclipse menu bar, choose Window > Preferences.
The Preferences window is displayed.
- In the navigation pane on the left, choose General > Workspace. In the Text file encoding area, select Other and set the value to UTF-8. Click Apply and then OK. Figure 1 shows the settings.
- On the Eclipse menu bar, choose Window > Preferences.
- Modify the sample. You can skip this step for a cluster with Kerberos authentication disabled.
After you obtain the krb5.conf and user.keytab files of the new development user in 4, change the value of userName in ExampleMain.java to the new username, for example, impalauser.
/** * Other way to set conf for zk. If use this way, * can ignore the way in the 'login' method */ if (isSecurityMode) { userName = "impalauser"; userKeytabFile = CONF_DIR + "user.keytab"; krb5File = CONF_DIR + "krb5.conf"; conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos"); conf.set(HADOOP_SECURITY_AUTHORIZATION, "true");
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