简体   繁体   中英

Access Hive Metadata using JDBC

I am trying to access Hive Metadata using JDBC. I have added all the jar files required in the classpath. I was following the tutorial from here- https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC

After adding all the jar files I tried to wrote a sample program to connect to Hive using Java. When I debug the code, as soon as it hit the below line.

Connection con = 
DriverManager.getConnection("jdbc:hive://lvsaishdc3in0001.lvs.host.com:10000/
default","", "");

I always get this exception. Not sure why is it happening. Can anyone help me how to fix this problem?

java.sql.SQLException: Could not establish connection to 
lvsaishdc3in0001.lvs.host.com:10000/default: java.net.ConnectException: Connection
timed out: connect

I started my Hive sever by logging into Putty and passing the hostname.

$ bash
bash-3.00$ cd /usr/local/bin
bash-3.00$ hive --service hiveserver
Starting Hive Thrift Server
12/07/03 08:07:11 INFO service.HiveServer: Starting hive server on port 10000

Hive server is pretty unsecured by itself. It doesn't eve require username/password for authentication. From my experience, the most typical configuration is to start Hive server on the same box as the application, make sure that this box is connected to the Hadoop cluster and to secure this box. This way your connection string is jdbc:hive://localhost:10000 and the security becomes not your headache, but a headache of your networking folks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM