This topic describes how to use Java Database Connectivity (JDBC) to connect to Impala.

Prerequisites

An E-MapReduce (EMR) Hadoop cluster is created, and Impala is selected from the optional services when you create the cluster. For more information, see Create a cluster.

Procedure

  1. Log on to the cluster in SSH mode. For more information, see Log on to a cluster.
  2. Download the Impala JDBC driver.

    Download the Impala JDBC driver from the Cloudera official website to the /usr/lib/hive-current/lib/ directory.

    To download the Impala JDBC driver, visit Impala JDBC Connector.

    You can connect to Impala by using the Hive 2 JDBC driver or the Impala JDBC driver provided by Cloudera.

  3. Run the following command to access the Beeline client:
    beeline
    If the information shown in the following figure is returned, the attempt to access the Beeline client is successful. Beeline
  4. Use JDBC to connect to Impala.
    Note If Lightweight Directory Access Protocol (LDAP) authentication is enabled for Impala, you can use only the Impala JDBC driver to connect to Impala.
    • Run the following command to connect to Impala by using the Hive 2 JDBC driver:
      !connect jdbc:hive2://emr-header-1:21050/;auth=noSasl;

      Enter your LDAP username and password as prompted.

    • Run the following command to connect to Impala by using the Impala JDBC driver:
      !connect jdbc:impala://emr-header-1:21050/default;AuthMech=3;UID=<user>;PWD=<password>;

      You must replace <user> in the command with your LDAP username and <password> with the password of the LDAP username. For more information about how to obtain the username and password, see Manage user accounts.

    After Impala is connected, you can perform SQL queries by using Impala.