Using JDBC or Beeline to Connect to HiveServer2

The method that HiveServer2 clients use to connect to HiveServer2 is based on the HiveServer2 Authentication method and the type of client.

Using ODBC to Connect to HiveServer2

For details on how to install and use ODBC to connect to Hive, see Using ODBC to Connect to HiveServer2.

Note: The client must have a valid MapR or Kerberos ticket.

Using JDBC or Beeline to Connect to HiveServer2

The default port for HiveServer2 is 10000.

HiveServer2 Authentication Connection Requirements
No Authentication

Connection String: jdbc:hive2://<hs2_hostname>:10000<database>; You must enter a valid user name.

For encryption, JDBC requires a truststore and an optional truststore password.

  • Connection String with Encryption: jdbc:hive2://<hs2_hostname>:10000/<database>;ssl=true;sslTrustStore=<path-to-truststore>;sslTrustStorePassword=<password>

  • Connection String with Encryption (truststore passed in JVM arguments): jdbc:hive2://<hs2_hostname>:<port>/<database>;ssl=true

    Note: Prior to connecting to an application that uses JDBC, such as Beeline, you can run the following command to pass the truststore parameters as Java arguments:
    export HADOOP_OPTS="-Djavax.net.ssl.trustStore=<path-to-trust-store-file>
    -Djavax.net.ssl.trustStorePassword=<password>" 
MapR-SASL (this is included as part of the secure by default configuration)

Connection String: jdbc:hive2://<hs2_hostname>:10000/<database>;auth=maprsasl;ssl=true;

MapR-SASL encryption is enabled by default. For more information, see Configuring JDBC Connection String with SSL Encryption Enabled or Disabled.

Connection for Java Application: Use the -D flag to append the JVM argument: -Dhadoop.login=maprsasl.

PAM

Connection String: jdbc:hive2://<hs2_hostname>:10000/<database>;user=<user>;password=<password>

PAM + SSL (this is included as part of the secure by default configuration)

Connection String: jdbc:hive2://<hs2_hostname>:10000/<database>;ssl=true;user=<user>;password=<password>. For more information, see Configuring JDBC Connection String with SSL Encryption Enabled or Disabled.

Kerberos

Connection String: jdbc:hive2://<hostname>:10000/default;principal=mapr/<FQDN@REALM>

Connection for Java Application: Use the -D flag to append the JVM argument: -Dhadoop.login=hybrid

Note: The client nodes must also have a Kerberos ticket and be configured to connect to HiveServer2 to use Kerberos.
LDAP Connection String: jdbc:hive2://<hs2_hostname>:10000/<database>;user=<ldap_user>;password=<ldap _password>