java.sql.SQLException:配置单元中的org.apache.thrift.transport.TTransportException? [英] java.sql.SQLException: org.apache.thrift.transport.TTransportException in hive?

查看:3318
本文介绍了java.sql.SQLException:配置单元中的org.apache.thrift.transport.TTransportException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用java配置蜂巢表。我发现



java.sql.SQLException:org.apache.thrift.transport.TTransportException



,同时执行我的代码。



这是我的代码

  public void createTable(String tableName) {
尝试{
Statement stat = con.createStatement(); (User_Name,VARCHAR(25),UserId VARCHAR(20),User_Pwd VARCHAR(15),主键(

String String QueryString =CREATE TABLE'+ tableName +'(User_Id INTEGER NOT NULL AUTO_INCREMENT, (用户名));

a = stat.executeUpdate(QueryString);
if(a == 1){
System.out.println(a);
System.out.println(Table has been created);
}

} catch(Exception e){
System.out.println(e);}
}

为什么抛出这个异常,我该如何解决它。

解决方案

这是一个非常通用的错误消息,描述 hiveserver 存在问题并提示您看一下Hive日志。如果您访问配置单元日志并找到异常调用堆栈,则可以找到根本原因或者如果共享该异常,我可以帮助您。



我见过的最常见问题是:


  1. 与并发性相关的元存储

  2. 当您将hive服务器作为 $ hive --service yourhiveserver 启动并保持运行数天后运行你的代码,有可能你的连接是代理服务器,你会得到完全相同的错误。如果你重新连接到服务器,这个错误将消失。这只是因为在一段时间wait_time过期并断开连接发生。

  3. 特定于端口的错误


请确保为您的Hive服务器设置一个开放端口,并在启动hive服务器之前将其设置为如下所示:

  $ export HIVE_PORT = 10000 
$ hive --service hiveserver
$ _run_your_code

可能还有其他原因,但是最好的选择是检查配置单元日志中的调用堆栈以解决问题。


I'm trying to create table in hive with java. I found

java.sql.SQLException: org.apache.thrift.transport.TTransportException

while executing my code.

Here is my code

public void createTable(String tableName) {
        try{
            Statement stat = con.createStatement();

        String QueryString = "CREATE TABLE '"+tableName+"'(User_Id INTEGER NOT NULL AUTO_INCREMENT, " + "User_Name VARCHAR(25), UserId VARCHAR(20), User_Pwd VARCHAR(15), primary key(User_Id))";

        a = stat.executeUpdate(QueryString);
        if(a==1){
            System.out.println(a);
            System.out.println("Table has been created");
        }

        }catch(Exception e){
        System.out.println(e);}
} 

Why this exception is thrown and how can i fix it.?

解决方案

It is a very generic error message describing that the hiveserver is having a problem and suggesting you to take a look at the Hive logs. If you access the hive logs and find the exception call stack, you can find the root cause or if you share the exception, I might be able to help you.

Most common problems I have seen as:

  1. Issues with meta store related with concurrency

  2. When you start hive server as $hive --service yourhiveserver and keep it running for days and then run your code, it is possible that your connection is broker to server and you will get exact same error. If you reconnect to server and this error will go away. This is only because after some time wait_time expired and disconnect happen.

  3. Port specific errors

Be sure to setup an open Port for your Hive Server and set it as below before starting hive server:

 $export HIVE_PORT=10000
 $hive --service hiveserver
 $ _run_your_code

There could be other reasons, however your best option is to check the call stack in hive logs to root cause and solve the problem.

这篇关于java.sql.SQLException:配置单元中的org.apache.thrift.transport.TTransportException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆