Hive2& JDBC - 必填字段'serverProtocolVersion'未设置 [英] Hive2 & JDBC - Required field 'serverProtocolVersion' is unset
本文介绍了Hive2& JDBC - 必填字段'serverProtocolVersion'未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用
Driver连接到配置单元org.apache.hive.jdbc.HiveDriver
I am trying to connect to hive using Driver org.apache.hive.jdbc.HiveDriver
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public void (String query)throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "", "");
Statement stmt = con.createStatement();
String tableName = "testHiveTable";
stmt.executeQuery("drop table " + tableName);
ResultSet res = stmt.executeQuery("create table " + tableName + " as "+query);
获取以下错误
Getting the following error
java.sql.SQLException: Could not establish connection to jdbc:hive2://localhost:10000/default: Required field 'serverProtocolVersion' is unset! Struct:TOpenSessionResp(status:TStatus(statusCode:SUCCESS_STATUS), serverProtocolVersion:null, sessionHandle:TSessionHandle(sessionId:THandleIdentifier(guid:4A D8 C1 6F 82 54 49 05 80 77 24 7D A2 3A 1D 9A, secret:21 9B BF EA 37 B6 49 60 BE 5F D2 13 98 E3 17 0B)), configuration:{})
推荐答案
我有同样的问题。在方法 getConnection 解决了我的问题。有关更多详细信息,请参见 HiveServer2文档。
I had the same issue. Setting username in method getConnection fixed my problem. Please see HiveServer2 documentation for more details.
这篇关于Hive2& JDBC - 必填字段'serverProtocolVersion'未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文