Installing the Hive JDBC Driver on Clients in CDH

To access the Hive server with JDBC clients, download the Cloudera Hive JDBC driver for HiveServer2 from the Cloudera web site.

Do not download the Apache Hive JDBC Driver for HiveServer2 that is defined in org.apache.hive.jdbc.HiveDriver.

Connection URLs

The HiveServer2 connection URL has the following format:

jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list
where:
  • <host1>:<port1>,<host2>:<port2> is a server instance or a comma separated list of server instances to connect to (if dynamic service discovery is enabled). If no server is mentioned here, the embedded server will be used.
  • dbName is the name of the initial database.
  • sess_var_list is a semicolon separated list of key=value pairs of session variables. For example, user=foo;password=bar.
  • hive_conf_list is a semicolon separated list of key=value pairs of Hive configuration variables for this session. For example, hive.server2.transport.mode=http;hive.server2.thrift.http.path=hs2.
  • hive_var_list is a semicolon separated list of key=value pairs of Hive variables for this session.
Connection URLs for Remote or Embedded Mode: For remote or embedded access, the JDBC Driver class is org.apache.hive.jdbc.HiveDriver.
  • For a remote server, the URL format is jdbc:hive2://<host>:<port>/<db>. The default HiveServer2 port is 10000).
  • For an embedded server, the URL format is jdbc:hive2:// (no host or port).
Connection URLs in HTTP Mode:
jdbc:hive2://<host>:<port>/<db>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=<http_endpoint>
where <http_endpoint> is the corresponding HTTP endpoint configured in hive-site.xml. The default value for the endpoint is cliservice. The default port for HTTP transport mode is 10001.
Connection URLs with SSL Enabled:
jdbc:hive2://<host>:<port>/<db>;ssl=true;sslTrustStore=<trust_store_path>;trustStorePassword=<trust_store_password>
where:
  • <trust_store_path> is the path where client's truststore file is located.
  • <trust_store_password> is the password to access the truststore.
In HTTP mode with SSL enabled, the URL is of the format:
jdbc:hive2://<host>:<port>/<db>;ssl=true;sslTrustStore=<trust_store_path>;trustStorePassword=<trust_store_password>?hive.server2.transport.mode=http;hive.server2.thrift.http.path=<http_endpoint>