You can connect to Impala through a JDBC client tool, such as the SQuirreL client. You can also use the driver in a Maven application.
Using the JDBC Driver with a Client Application
Before you connect to Impala from a JDBC client tool, complete the following tasks:
- Configure the JDBC port.
- Download the JDBC driver files and enable the driver on each machine that runs the JDBC-enabled application.
- Update the CLASSPATH to include the driver and the dependencies.
- Specify a connection string for the JDBC application to access one of the servers running the
1. Configuring the JDBC Port
The default JDBC port that Impala accepts connections through is port 21050. Verify that this port can communicate with other hosts on your network. If your JDBC application connects through a different port, use the - - hs2_port option when you start
impalad to specify the port number.
2. Enabling the JDBC Driver on Client Machines
The JDBC driver is packaged in JAR files. From a system that has Hive installed, download the following JAR files to each client machine.
- The JDBC driver is in
hadoop-0.20.2-dev-core.jarfile for MRv1 is in
hadoop-common-2.7.0 jar file for MRv2 (YARN)is in
- The other required JAR files are in
Download the following JARs:
Note that you may have a different Hive 1.2 version installed. This list pertains to the 1601 version of Hive 1.2.
You also need the
slf4j-log4j12-1.7.5.jar files, which are available in
3. Updating the CLASSPATH
The client application needs to locate the JAR files. Set the
CLASSPATH for the client process to include the JARs. Consult the documentation for your JDBC client application for more details on how to install new JDBC drivers.
If the existing
CLASSPATH on your client machine refers to an older version of the Hive JARs, verify that the new JARs are listed first. You can put the new JAR files ahead of the older JAR files, or delete the other references to Hive JAR files.
4. Specifying a Connection String
Specify a connection string to establish a connection between Impala and JDBC. The JDBC driver classpath is org.apache.hive.jdbc.HiveDriver.Use the following connection string to establish the connection:
Using the JDBC Driver in a Maven Application
To use the JDBC driver in a Maven application, complete the following steps:
- Configure a MapR Maven repository. Refer to Maven Artifacts for MapR to configure MapR’s Maven repository in your Java application.
Add the following dependency in the
Specify the connection string in the Java application. The following code shows a working example: