Hive JDBC getConnection not returning

I follow the Jive tutorial for the hive. I could not get it to work. When it tries to get a connection, it just freezes. It also does not report an error. I am sure that 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(); } } } 

netstat output:

 $ 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 
+4
source share
3 answers

Naresh: try stopping the triffserver, then go to the HIVE_HOME / bin directory from your terminal, then start the hive trift server using ./hive -service hiveserver 10000 & . Then try to run the program. Create a table according to the example of a bush wiki client. Then run the show tables query in the next step. Let us know the result after completing these steps. After that we can discuss.

+1
source

You can do the following to determine where the hang is. Here is an example I did to trace it in my broken Jive junction. Please note that this is not a specific solution for any common hanging connection error.

This is the answer to the question: "How can I find out where my connection to JDBC bushes hangs?"

For this, it is difficult to track a dynamic JDBC call. Instead, you can simply create the HiveConnection () class. This allows you to directly add tracing to your code to see where the freeze occurs.

I tracked this by doing the following.

* USING LOG4J *

Sighting and other JDBC hive classes use log4j when connecting, if you enable DEBUG logging, you may see fine-grained errors. You can do it easily by adding

BasicConfigurator.configure()

To your client application. In any case, this led me to conclude that it was like a stall in the SASL transport layer. I suppose this may be related to security, but I would suggest that a security error will return STILL and not hang ... Therefore, I think it might be worthy of JIRA. I inserted the following question:

How to track the rejection of TSaslTransport (associated with the hive)

* ANOTHER METHOD *

1) You can grab a copy of the "HiveConnection" class from github or anywhere and create a new instance:

String url=String.format("jdbc:hive2://%s:%s/default", server, port) Properties p = new Properties(); p.setProperty("host", con); Connection jdbc = new HiveConnection(url,p);

You can then add your debugger hooks or log statements to the HiveConnection () class.

Verbally, when I had this error, I traced it:

openTransport

What ultimately creates

org.apache.thrift.transport.TSaslClientTransport

instance.

And in this code block there is a hang:

try { System.out.println(".....1 carrying on... attempting to open. " + transport.getClass().getName()); transport.open(); System.out.println("done open."); } catch (TTransportException e) { System.out.println("2 fail ."); e.printStackTrace(); throw new SQLException("Could not establish connection to " + uri + ": " + e.getMessage(), " 08S01"); }

FYI I posted information on why the MY connection failed. This may be related to yours ... How to trace the rejection of TSaslTransport (associated with the hive)

+1
source

I had the same problem / Check these options:

 driverName = "org.apache.hive.jdbc.HiveDriver" con = DriverManager.getConnection("jdbc:hive2://192.168.1.93:10000/default", "", ""); 
0
source

All Articles