当通过JDBC方式访问Hive数据库时,可以通过在连接参数中将“AuthMech”设置为不同的值来使用不同的鉴权方式,如下给出各种鉴权方式的连接串示例
-
不使用鉴权:在连接参数中将“AuthMech”属性设置为“0”
连接串示例:
jdbc:hive2://IPAddress:Port;AuthMech=0
-
使用Kerbors鉴权:在连接参数中将“AuthMech”属性设置为“1”
连接串示例:
jdbc:hive2://IPAddress:Port;AuthMech=1;KrbRealm=EXAMPLE.COM;KrbHostFQDN=hs2.example.com;KrbServiceName=hive
-
使用用户名鉴权:在连接参数中将“AuthMech”属性设置为“2”
连接串示例:
jdbc:hive2://IPAddress:Port;AuthMech=2;UID=hs2
-
使用用户名和密码鉴权:在连接参数中将“AuthMech”属性设置为“3”
连接串示例:
jdbc:hive2://IPAddress:Port;AuthMech=3;UID=hs2;PWD=****
-
在安全套接字层使用用户名和密码鉴权:在连接参数中将“AuthMech”属性设置为“4”
连接串示例:
jdbc:hive2://IPAddress:Port;AuthMech=4;SSLKeyStore=C:\\Users\\bsmith\\Desktop\\Keystore.jks;SSLKeyStorePwd=****;UID=hs2;PWD=****