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 Kerberos ticket.

Using JDBC or Beeline to Connect to HiveServer2

HiveServer2 Authentication Connection Requirements
No Authentication

Connection String: jdbc:hive2://<hostname>:10000/default

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

  • Connection String with Encryption:jdbc:hive2://<host>:<port>/<database>;ssl=true;sslTrustStore=<path-to-truststore>;sslTrustStorePassword=<password>
  • Connection String with Encryption (truststore passed in JVM arguments): jdbc:hive2://<host>:<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="<path-to-trust-store-file><password>"

Connection String: jdbc:hive2://<hostname>:10000/default;auth=maprsasl

Connection String with Encryption (Hive 0.13 version):jdbc:hive2://<hostname>:10000/default;auth=maprsasl;sasl.qop=auth-conf

Connection String with Encryption (Hive 1.0 version):jdbc:hive2://<hostname>:10000/default;auth=maprsasl;saslQop=auth-conf

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


Connection String: jdbc:hive2://hs2node:10000/default;user=<userid>;password=<password>


Connection String for MapR-SASL (Hive 2.3 and 2.1 version): !connect jdbc:hive2://<hostname>:10000/default;auth=maprsasl; (MapRSASL encryption enabled)

Connection String for PAM connection + SSL on MapR-SASL cluster (Hive 2.3 and 2.1 version): !connect jdbc:hive2://<hostname>:10000/default;ssl=true;sslTrustStore=/opt/mapr/conf/ssl_truststore username password

For example:
beeline> !connect jdbc:hive2://node4:10000/default;ssl=true;
Connecting to jdbc:hive2://node4:10000/default;ssl=true;
Enter username for jdbc:hive2://node4:10000/default: test
Enter password for jdbc:hive2://node4:10000/default: ****
Connected to: Apache Hive (version 2.3.3-mapr)
Driver: Hive JDBC (version 2.3.3-mapr)

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

Connection String with Encryption (Hive 0.13 version):jdbc:hive2://<hostname>:10000/default;principal=mapr/<FQDN@REALM>;sasl.qop=auth-conf

Connection String with Encryption (Hive 1.0 version): jdbc:hive2://<hostname>:10000/default;principal=mapr/<FQDN@REALM>;saslQop=auth-conf

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 using Kerberos.
LDAP Connection String: jdbc:hive2://hs2node:10000/default;user=<userid>;password=<password>