java - Hive2 & JDBC - 必填字段 'serverProtocolVersion' 未设置

标签 java hadoop jdbc hive

我正在尝试使用以下方式连接到配置单元 驱动 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);

出现以下错误

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 documentation了解更多详情。

关于java - Hive2 & JDBC - 必填字段 'serverProtocolVersion' 未设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27614723/

相关文章:

java - Google Appengine 上的 GWT 上传 - 跨站点保护

java - Play Framework 和 jdbc 阻塞 io 调用是否有主要的扩展限制

hadoop - 请澄清我对 Hadoop/HBase 的理解

linux - 伪分布式运行Hadoop时,hadoop.tmp.dir应该放在什么目录下?

java - 针对 Hyper-V VM 中运行的 SQL Server 诊断缓慢的 JDBC 选择语句

java - 线程在 DriverManager.getConnection 上挂起

java - 使用 Spring Security 时获取当前登录的用户名

java - 如果我只想在其中使用 Java,Eclipse 和 Netbeans 有什么区别?

java - 可运行更改错误的单元格

hadoop - 我们可以插入外部表吗