getConnection不返回

getConnection不返回

本文介绍了Hive JDBC getConnection不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注配置单元JDBC教程。我无法得到它的工作。当它试图获得连接时,它只是挂起。它也不报告任何错误。我确定Hive服务器正在运行。任何帮助?

  public class HiveJdbcClient {
private static String driverName =org.apache.hadoop.hive.jdbc .HiveDriver;
public static void main(String [] args){
try {
Class.forName(driverName);
} catch(ClassNotFoundException e){
e.printStackTrace();
System.exit(1);


try {
Connection con = DriverManager.getConnection(jdbc:hive:// localhost:10000 / default,,);
System.out.println(有连接);

catch(SQLException e){
e.printStackTrace();
}
}
}

netstat的输出:

  $ sudo netstat -anlp | grep 10000 
密码:
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN 27738 / java
tcp 107 0 127.0.0.1:10000 127.0.0.1:45910 ESTABLISHED 27738 / java
tcp 0 0 127.0.0.1:33665 127.0.0.1:10000 ESTABLISHED 24475 / java
tcp 0 0 127.0.0.1:45910 127.0.0.1:10000 ESTABLISHED 7445 / java
tcp 107 0 127.0 .0.1:10000 127.0.0.1:33665 ESTABLISHED 27738 / java


解决方案

Naresh:尝试停止triffserver,然后转到终端的 HIVE_HOME / bin 目录,然后使用 ./ hive --service hiveserver 10000& 命令。然后尝试运行该程序。根据hive客户端wiki示例创建一个表。然后在下一步中做一个显示表查询。一旦遵循这些步骤,让我们知道结果。之后我们可以进行讨论。

I'm following the hive JDBC tutorial. I could not get it working. When it try to get the connection it just hangs. It does not report any error either. I'm sure the Hive server is running. Any help?

public class HiveJdbcClient {
  private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
  public static void main(String[] args){
      try {
      Class.forName(driverName);
    } catch (ClassNotFoundException e) {
           e.printStackTrace();
      System.exit(1);
    }

    try{
        Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
        System.out.println("got the connection");

    }catch(SQLException e){
        e.printStackTrace();
    }
  }
}

output of the netstat:

$ sudo netstat -anlp | grep 10000
Password:
tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      27738/java
tcp      107      0 127.0.0.1:10000             127.0.0.1:45910             ESTABLISHED 27738/java
tcp        0      0 127.0.0.1:33665             127.0.0.1:10000             ESTABLISHED 24475/java
tcp        0      0 127.0.0.1:45910             127.0.0.1:10000             ESTABLISHED 7445/java
tcp      107      0 127.0.0.1:10000             127.0.0.1:33665             ESTABLISHED 27738/java
解决方案

Naresh: Try stopping the triffserver, then move to the HIVE_HOME/bin directory from your terminal, then start the hive trift server using the ./hive --service hiveserver 10000 & command. Then try running the program. Do a create table as per the hive client wiki example . Then do a show tables query in the next step. Let us know the result once this steps are followed. We can have a discussion after that.

这篇关于Hive JDBC getConnection不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:12