Community Articles
Find and share helpful community-sourced technical articles
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)

Beeline is a JDBC client tool which is used to connect to HiveServer2 or HiveServer2Interactive(LLAP). Beeline, which connects to HiveServer2 and requires access to only one .jar file: hive-jdbc-<version>-standalone.jar

Hortonworks recommends using HiveServer2 and a JDBC client (such as Beeline) as the primary way to access Hive. This approach uses SQL standard-based authorization or Ranger-based authorization. However, some users may wish to access Hive data from other applications, such as Pig. For these use cases, use the Hive CLI and storage-based authorization.

Connecting to Hive with Beeline

The following examples demonstrate how to use Beeline to connect to Hive for all possible variations of these modes.

Embedded Client

Use the following syntax to connect to Hive from Beeline in embedded mode:

!connect jdbc:hive2://

Remote Client with HiveServer2 TCP Transport Mode and SASL Authentication

Use the following syntax to connect to HiveServer2 in TCP mode from a remote Beeline client:

!connect jdbc:hive2://<hiveserver2host>:<port>/<db>

The default port for HiveServer2 in TCP mode is 10000, and db is the name of the database to which you want to connect.

Connecting to HiveServer2 using Zookeeper Discovery Mode

Note: You can also find the below HiveServer2 JDBC URL from Ambari from Hive -> Summary page. To copy the JDBC URL, you can use the copy to clipboard icon next to the URL

Observe the / after the <ZOOKEEPER QUORUM> in each string below

- HiveServer2 using Binary Transport Mode:

jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2HiveServer2 

- HiveServer2 using HTTP Transport Mode:

jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice
Connection String for connection to HiveServer2Interactive
Look for zooKeeperNamespace=hiveserver2-hive2 in the below URL
jdbc:hive2://<ZOOKEEPER QUORUM>/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2
For running Hive Scripts using Beeline, you can make use of -f option in Beeline.
beeline -u "jdbc:hive2://master01:2181,master02:2181,master03:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -f file.hql 
Please refer above article for Beeline command options and examples for getting started with Beeline.


@Tamil Selvan K nice article !!

Not applicable

I believe, Beeline JDBC client can also be used to connect to Spark SQL thru Spark Thrift server.

Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎12-23-2017 07:36 PM
Updated by:
Contributor tsk Contributor
Top Kudoed Authors