背景

hive jdbc 的驱动并不是通用的,链接 hive 需要对应版本的 jdbc 驱动

要不然可能会这样:

1
The specified database user/password combination is rejected: [ 08S01] Could not open client transport with JDBC Uri: jdbc:hive2://192.168.1.***:10000: Could not establish connection to jdbc:hive2://192.168.1.***:10000: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default}) [ 08S01] Could not establish connection to jdbc:hive2://192.168.1.***:10000: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default})
  • 以 hive 1.2.1 版本为例

驱动

  • hive 1.2.1, 下载 standalone jar
    https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/1.2.1

  • hadoop common 2.10.0 (这个版本需要根据具体的 hdfs 版本来确认,选择 2.10.0 也不是不行
    https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common/2.10.0

如果没有 hadoop common 包的话,会这样

1
Driver class 'org.apache.hadoop.conf.Configuration' not found.

添加 User Driver