1

I am looking for a JAVA code to connect to a HIVE DB using Cloudera HIVE drivers, which needs Kerberos Authentication. Over the net I can only find codes with Apache Drivers, is there a difference? Can someone put forward some suggestion?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • Why do you need "code"? JDBC is JDBC, only the URL syntax differs. – Samson Scharfrichter May 27 '19 at 07:41
  • About Kerberos auth: either you have a valid ticket in the default Java cache, or you specify login/pwd via JAAS config cf. https://stackoverflow.com/a/42506620/5162372 , or you prompt for pwd at connect time _(requires an override to default Java `security` config)_ – Samson Scharfrichter May 27 '19 at 07:47
  • Caveat: running against Kerberised Hadoop from Windows is trickier, especially SSO. Apache driver has extra problems, with cascade deps on "native libs" (i.e. DLL) that have no official build, but Cloudera drivers spare you that burden. – Samson Scharfrichter May 27 '19 at 07:51

1 Answers1

1

You can download the Cloudera hive drivers directly from the official Cloudera website. Yes it is not the same as the apache driver as Cloudera releases their own version of the driver.

Along with the driver, you will find the official documentation to connect to hive using kerberos.

A sample connection Jdbc url is as below:

jdbc:hive2://node1.example.com:10000;AuthMech=1; KrbRealm=EXAMPLE.COM;KrbHostFQDN=hs2node1.example.com; KrbServiceName=hive;KrbAuthType=2

AuthMech = 1 enables kerberos connection and the rest is straightforward code to connect to kerberos using the realm and service information.

Note: You need to download the right driver as per your installation.

Hope this help :)

Rishu Shrivastava
  • 3,745
  • 1
  • 20
  • 41