Hive2& JDBC - 必填字段&serverConrotocolVersion'没有设定

时间:2014-12-23 05:44:01

标签: 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:{})

1 个答案:

答案 0 :(得分:1)

我有同样的问题。在方法getConnection中设置用户名修复了我的问题。有关详细信息,请参阅HiveServer2 documentation