【问题标题】:Not able to get Connect to Hive version (2.1.0.2.6.3.0-235)无法获得 Connect to Hive 版本 (2.1.0.2.6.3.0-235)
【发布时间】:2019-07-28 06:21:26
【问题描述】:

无法通过下面的 java 代码连接到 Hive 2.1.0.2.6.3.0-235

遇到错误

ERROR org.apache.hive.jdbc.Utils - Unable to read HiveServer2 configs from ZooKeeper
Exception in thread "main" java.sql.SQLException: Could not open client transport for any of the Server URI's in ZooKeeper: Failed to open new session: java.lang.IllegalArgumentException: hive configuration hive.server2.thrift.resultset.default.fetch.size does not exists.

我使用过以下 Gradle 依赖:

compile group: 'org.apache.hive', name: 'hive-jdbc', version: '3.1.1'
compile group: 'org.apache.hive', name: 'hive-metastore', version: '3.1.1'
compile group: 'org.apache.hive', name: 'hive-exec', version: '3.1.1'
compile group: 'org.apache.hive', name: 'hive-cli', version: '3.1.1'
compile group: 'org.apache.hive', name: 'hive-service', version: '3.1.1'

下面是我的代码:

import java.sql.Connection
import java.sql.DriverManager

class Hive2ConnectionTest {


    static String driverClassName = "org.apache.hive.jdbc.HiveDriver"
    static String url = "jdbc:hive2://<ip>:<port>/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2"

    static String dbUsername = "username"
    static String dbPassword = "password"

    static void main(String[] args)throws  IOException{

        try {
            Class.forName(driverClassName);
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }

        Connection con = (Connection)DriverManager.getConnection(url, dbUsername, dbPassword);

    }

}

我也尝试过其他 gradle 依赖版本,但无法连接

version: '1.2.1000.2.4.2.10-1'
version: '2.1.0.2.6.3.0-235'

【问题讨论】:

  • 你能在 hiveserver2 路径下检查你的 ZK 命名空间吗?

标签: java hive bigdata database-connection jdbctemplate


【解决方案1】:

我认为有些版本不匹配,以下依赖项对我有用。

compile ("javax.servlet:javax.servlet-api:3.1.0")
compile ("org.apache.hive:hive-jdbc:2.2.0")
compile ("org.apache.hive:hive-metastore:3.1.1") 

请试一试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 2019-06-20
    • 2017-04-17
    相关资源
    最近更新 更多