Using a Connection String

For some applications, you might need to use a connection string to connect to your data source. For detailed information about how to use a connection string in an ODBC application, refer to the documentation for the application that you are using.

The connection strings in the following sections are examples showing the minimum set of connection attributes that you must specify to successfully connect to the data source. Depending on the configuration of the data source and the type of connection you are working with, you might need to specify additional connection attributes. For detailed information about all the attributes that you can use in the connection string, .

DSN Connection String Example

The following is an example of a connection string for a connection that uses a DSN:

DSN=[DataSourceName]

[DataSourceName] is the DSN that you are using for the connection.

You can set additional configuration options by appending key-value pairs to the connection string. Configuration options that are passed in using a connection string take precedence over configuration options that are set in the DSN.

DSN-less Connection String Examples

Some applications provide support for connecting to a data source using a connector without a DSN. To connect to a data source without using a DSN, use a connection string instead.

The placeholders in the examples are defined as follows, in alphabetical order:

  • [DomainName] is the fully qualified domain name of the Hive server host.
  • [Namespace] is the namespace on ZooKeeper under which Hive Server 2 znodes are added.
  • [PortNumber] is the number of the TCP port that the Hive server uses to listen for client connections.
  • [Realm] is the Kerberos realm of the Hive server host.
  • [Server] is the IP address or host name of the Hive server to which you are connecting.
  • [ServerURL] is the partial URL corresponding to the Hive server.
  • [ServiceName] is the Kerberos service principal name of the Hive server.
  • [YourPassword] is the password corresponding to your user name.
  • [YourUserName] is the user name that you use to access the Hive server.

Connecting to a Hive Server 1 Instance

The following is the format of a DSN-less connection string that connects to a Hive Server 1 instance:

Driver=Simba Hive ODBC Driver;HiveServerType=1;
Host=[Server];Port=[PortNumber];

For example:

Driver=Simba Hive ODBC Driver;HiveServerType=1;
Host=192.168.222.160;Port=10000;

Connecting to a Standard Hive Server 2 Instance

The following is the format of a DSN-less connection string for a standard connection to a Hive Server 2 instance. By default, the connector is configured to connect to a Hive Server 2 instance that requires User Name authentication, and the connector uses anonymous as the user name.

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;

Connecting using Dynamic Service Discovery

The following is the format of a DSN-less connection string that discovers Hive Server 2 services via the ZooKeeper service.

Driver=Simba Hive ODBC Driver;ServiceDiscoveryMode=1;
Host=[Server1]:[PortNumber1], [Server2]:[PortNumber2], [Server3]:[PortNumber3];ZKNamespace=[Namespace];

For example:

Driver=Simba Hive ODBC Driver;ServiceDiscoveryMode=1;
Host=192.168.222.160:10000, 192.168.222.165:10000, 192.168.222.231:10000;ZKNamespace=hiveserver;

Connecting to a Hive Server 2 Instance Without Authentication

The following is the format of a DSN-less connection string for a Hive Server 2 instance that does not require authentication.

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];AuthMech=0;

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;AuthMech=0;

Connecting to a Hive Server that Requires Kerberos Authentication

The following is the format of a DSN-less connection string that connects to a Hive Server 2 instance requiring Kerberos authentication:

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];AuthMech=1;KrbRealm=[Realm];
KrbHostFQDN=[DomainName];KrbServiceName=[ServiceName];

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;AuthMech=1;KrbRealm=SIMBA;
KrbHostFQDN=localhost.localdomain;KrbServiceName=hive;

Connecting to a Hive Server using SAML 2.0

The following is the format of a DSN-less connection string that connects to a Hive Server 2 instance via Single Sign-On using SAML 2.0 authentication:

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];AuthMech=12;ThriftTransport=2;HTTPPath=[ServerURL];SSL=1;

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;AuthMech=12;ThriftTransport=2;HTTPPath=cliservice;SSL=1;

Connecting to a Hive Server that Requires User Name And Password Authentication (LDAP)

The following is the format of a DSN-less connection string that connects to a Hive Server 2 instance requiring User Name And Password authentication:

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];AuthMech=3;UID=[YourUserName];
PWD=[YourPassword];

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;AuthMech=3;UID=simba;PWD=simba;

Connecting to a Hive Server on Windows Azure HDInsight Service

The following is the format of a DSN-less connection string that connects to a Hive Server 2 instance running on Windows Azure HDInsight Service:

Driver=Simba Hive ODBC Driver;Host=[Server];
Port=[PortNumber];AuthMech=6;SSL=1;UID=[YourUserName];
PWD=[YourPassword];HTTPPath=[ServerURL];

For example:

Driver=Simba Hive ODBC Driver;Host=192.168.222.160;
Port=10000;AuthMech=6;SSL=1;UID=simba;PWD=simba;
HTTPPath=gateway/sandbox/hive;