无法通过下面的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'
1条答案
按热度按时间a7qyws3x1#
我认为有一些版本不匹配,以下依赖为我工作。
请试一试。