Spark Guide
Also available as:
PDF
loading table of contents...

Forming JDBC Connection Strings for Spark SQL

JDBC URL connection strings have the following format:

jdbc:hive2://<host>:<port>/<dbName>;<sessionConfs>?<hiveConfs>#<hiveVars>

JDBC ParameterDescription
hostThe node hosting the Thrift Server.
portThe port number on which the Thrift Server listens.
dbNameThe name of the Hive database to run the query against.
sessionConfsOptional configuration parameters for the JDBC driver, in the following format: <key1>=<value1>;<key2>=<key2>...;
hiveConfs

Optional configuration parameters for Hive on the server in the following format: <key1>=<value1>;<key2>=<key2>; ...

These settings last for the duration of the user session.

hiveVars

Optional configuration parameters for Hive variables in the following format: <key1>=<value1>;<key2>=<key2>; ...

These settings last for the duration of the user session.

[Note]Note

The Spark Thrift Server is a variant of HiveServer2, so you can use many of the same settings. For more information, including transport and security settings, see Hive JDBC and ODBC Drivers in the HDP Data Services Guide.

Accessing Spark via JDBC on a Kerberos-enabled Cluster

The following connection URL accesses Spark SQL via JDBC on a Kerberos-enabled cluster:

beeline> !connect jdbc:hive2://localhost:10002/default;httpPath=/;principal=hive/hdp-team.example.com@EXAMPLE.COM

The following connection URL accesses Spark SQL via JDBC over HTTP transport on a Kerberos-enabled cluster:

beeline> !connect jdbc:hive2://localhost:10002/default;transportMode=http;httpPath=/;principal=hive/hdp-team.example.com@EXAMPLE.COM