无法连接到配置单元版本(2.1.0.2.6.3.0-235)

8iwquhpp  于 2021-06-27  发布在  Hive
关注(0)|答案(1)|浏览(462)

无法通过下面的java代码连接到Hive2.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.

我使用了以下渐变依赖:

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'
a7qyws3x

a7qyws3x1#

我认为有一些版本不匹配,以下依赖为我工作。

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")

请试一试。

相关问题