我安装了hortonworks,我尝试通过jdbc访问hiveserver2。但我得到了错误
ERROR : unsupported hive2 protocol
代码:
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
System.out.println("error");
}
java.sql.Connection con = DriverManager.getConnection("jdbc:hive2://192.168.0.96:10000/db","id","pwd");
程序版本:
这种情况有什么解决办法吗?
最佳答案
正如@climbage 所提到的,您的客户端代码和配置单元服务器使用的协议(protocol)版本不匹配。
这是拒绝请求的特定配置单元源代码(在 Hive Connection source code
私有(private) void openSession(Map sessVars) 抛出 SQLException {
TOpenSessionReq openReq = new TOpenSessionReq();
..
try {
TOpenSessionResp openResp = client.OpenSession(openReq);
// validate connection
Utils.verifySuccess(openResp.getStatus());
if (!supportedProtocols.contains(openResp.getServerProtocolVersion())) {
throw new TException("Unsupported Hive2 protocol");
}
我的建议:查看部署在您的服务器上的特定版本的 hive 的 core-hive 模块中的 src/test 代码。他们将有 jdbc 测试,您可以将其“提升”到您的客户端代码中。
另外,您是否只是尝试过 hive 而不是 hive2?
Connection con = DriverManager.getConnection("jdbc:hive://192.168.56.101:10000/default", "root", "");
关于hadoop - Hortonworks hiveserver2 jdbc错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23547710/