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:

  1. Configure the JDBC port.
  2. Download the JDBC driver files and enable the driver on each machine that runs the JDBC-enabled application.
  3. Update the CLASSPATH to include the driver and the dependencies.
  4. Specify a connection string for the JDBC application to access one of the servers running the impalad daemon.

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 /opt/mapr/hive/hive-1.2/lib/hive-jdbc-1.2.0-mapr-1601.jar.
  • The hadoop-0.20.2-dev-core.jar file for MRv1 is in /opt/mapr/hadoop/hadoop-0.20.2/lib.
  • The hadoop-common-2.7.0 jar file for MRv2 (YARN) is in /opt/mapr/hadoop/hadoop-2.7.0/share/hadoop/common.
  • The other required JAR files are in /opt/mapr/hive/hive-1.2/lib/. 

Download the following JARs:


  • commons-logging-1.1.3.jar
  • guava-14.0.1.jar
  • hive-exec-1.2.0-mapr-1601.jar
  • hive-jdbc-1.2.0-mapr-1601.jar
  • hive-metastore-1.2.0-mapr-1601.jar
  • hive-service-1.2.0-mapr-1601.jar
  • hive-shims-1.2.0-mapr-1601.jar
  • httpclient-4.4.jar
  • httpcore-4.4.jar
  • libfb303-0.9.2.jar
  • libthrift-0.9.2.jar

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-api-1.7.5.jar and slf4j-log4j12-1.7.5.jar files, which are available in /opt/mapr/lib.

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:

  1. Configure a MapR Maven repository. Refer to Maven Artifacts for MapR to configure MapR’s Maven repository in your Java application.
  2. Add the following dependency in the pom.xml:

  3. Specify the connection string in the Java application. The following code shows a working example:

    import java.sql.*;
    public class ImpalaJdbcExample
           private static String connectionString = "jdbc:hive2://;auth=noSasl";
           private static String driverName = "org.apache.hive.jdbc.HiveDriver";
           private static String queryString = "select count(*) from customers";
           private static Connection con;
           private static ResultSet resultSet;
           private static Statement sqlStatement;
           public static void main(String[] args)
                   System.out.println("Loaded the driver successfully. Trying to establish connection");
                           con = DriverManager.getConnection(connectionString);
                           System.out.println("Created connection. Preparing statement");
                           sqlStatement = con.createStatement();
                           System.out.println("Executing "+queryString);
                           resultSet = sqlStatement.executeQuery(queryString);
                                   System.out.println("Result set "+resultSet.getString(1));
    			   catch(SQLException sqle)
                           System.out.println("Got sql exception");
                   catch(Exception e)
                           System.out.println("Got exception");