Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
793 views
in Technique[技术] by (71.8m points)

hadoop - java.sql.SQLException: org.apache.thrift.transport.TTransportException in hive?

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.?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...