Amazon Elastic MapReduce
Developer Guide (API Version 2009-03-31)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Use the Hive JDBC Driver

The Hive JDBC driver provides a mechanism to move data from one database format to another. Installing a JDBC client requires you to download the JDBC driver and install the client software correctly. You can use the Hive JDBC driver to connect to a SQL client. An example of connecting to the SQuirrel SQL client follows.

To download JDBC drivers

You need only download the drivers appropriate to the version(s) of Hive you want to access.

To install SQuirrel SQL client

  1. Download SQuirrel SQL client from http://squirrel-sql.sourceforge.net/.

  2. Open the self extracting JAR file, and follow the wizard instructions to install the software.

  3. From the command line, create an SSH tunnel to the master node of your Hive job flow as follows:

    If you are installing...Enter the following...
    Hive 0.11.0 drivers ssh -o ServerAliveInterval=10 -L 10004:localhost:10004 hadoop@MasterNodeDNS -i $HOME/mysecretkey.pem
    Hive 0.8.1 drivers ssh -o ServerAliveInterval=10 -L 10003:localhost:10003 hadoop@MasterNodeDNS -i $HOME/mysecretkey.pem
    Hive 0.7.1 drivers ssh -o ServerAliveInterval=10 -L 10002:localhost:10002 hadoop@MasterNodeDNS -i $HOME/mysecretkey.pem
    Hive 0.7 drivers ssh -o ServerAliveInterval=10 -L 10001:localhost:10001 hadoop@MasterNodeDNS -i $HOME/mysecretkey.pem
    Hive 0.5 drivers ssh -o ServerAliveInterval=10 -L 10000:localhost:10000 hadoop@MasterNodeDNS -i $HOME/mysecretkey.pem

    The MasterNodeDNS is the public DNS name of the master node of the Hadoop cluster and mysecretkey.pem is the name of your AWS secret key file.

  4. Add the JDBC driver to SQuirrel SQL:

    1. Open SQuirrel SQL and click the Drivers tab.

    2. Double-click JDBC ODBC Bridge to add attributes.

    3. Type org.apache.hadoop.hive.jdbc.HiveDriver in the Class Name field, and then click Add.

    4. Navigate to the location of your JDBC drivers.

    5. Add the following JAR files:

      If you are installing...Add the following...
      Hive 0.11.0 drivers
      hadoop-core-1.0.3.jar
      hive/lib/hive-exec-0.11.0.jar
      hive/lib/hive-jdbc-0.11.0.jar
      hive/lib/hive-metastore-0.11.0.jar
      hive/lib/hive-service-0.11.0.jar
      hive/lib/libfb303-0.9.0.jar
      lib/commons-logging-1.0.4.jar
      slf4j-api-1.6.1.jar
      Hive 0.8.1 drivers
      hadoop-core-1.0.3.jar
      hive/lib/hive-exec-0.8.1.jar
      hive/lib/hive-jdbc-0.8.1.jar
      hive/lib/hive-metastore-0.8.1.jar
      hive/lib/hive-service-0.8.1.jar
      hive/lib/libfb303.jar
      lib/commons-logging-1.0.4.jar    
      slf4j-api-1.6.1.jar
      slf4j-log4j12-1.6.1.jar         
      Hive 0.7.1 drivers
      hadoop-0.20-core.jar
      hive/lib/hive-exec-0.7.1.jar
      hive/lib/hive-jdbc-0.7.1.jar
      hive/lib/hive-metastore-0.7.1.jar
      hive/lib/hive-service-0.7.1.jar
      hive/lib/libfb303.jar
      lib/commons-logging-1.0.4.jar    
      slf4j-api-1.6.1.jar
      slf4j-log4j12-1.6.1.jar         
      Hive 0.7 drivers
      hadoop-0.20-core.jar
      hive/lib/hive-exec-0.7.0.jar
      hive/lib/hive-jdbc-0.7.0.jar
      hive/lib/hive-metastore-0.7.0.jar
      hive/lib/hive-service-0.7.0.jar
      hive/lib/libfb303.jar
      lib/commons-logging-1.0.4.jar    
      slf4j-api-1.5.6.jar
      slf4j-log4j12-1.5.6.jar         
      Hive 0.5 drivers
      hadoop-0.20-core.jar
      hive/lib/hive-exec-0.5.0.jar
      hive/lib/hive-jdbc-0.5.0.jar
      hive/lib/hive-metastore-0.5.0.jar
      hive/lib/hive-service-0.5.0.jar
      hive/lib/libfb303.jar
      hive/lib/log4j-1.2.15.jar
      lib/commons-logging-1.0.4.jar             
    6. Click OK.

  5. Add a new alias:

    1. Click the Alias tab, and then click + to add a new alias.

    2. Enter the following information in the Add Alias dialog:

      FieldDescription
      NameEnter the name of the alias.
      DriverSelect the JDBC driver from the list.
      User NameEnter your local machine login.
      PasswordEnter your local machine password.
    3. Enter the URL information in the Add Alias dialog based on the version of Hive:

      If you are installing...Enter the following...
      Hive 0.11.0 drivers jdbc:hive://localhost:10004/default
      Hive 0.8.1 drivers jdbc:hive://localhost:10003/default
      Hive 0.7.1 drivers jdbc:hive://localhost:10002/default
      Hive 0.7 drivers jdbc:hive://localhost:10001/default
      Hive 0.5 drivers jdbc:hive://localhost:10000/default
    4. Click OK.

The SQuirrel SQL client is ready to use.

For more information about using Hive and the JDBC interface, go to http://wiki.apache.org/hadoop/Hive/HiveClient and http://wiki.apache.org/hadoop/Hive/HiveJDBCInterface.