简体   繁体   English

使用JDBC访问Hive元数据

[英]Access Hive Metadata using JDBC

I am trying to access Hive Metadata using JDBC. 我正在尝试使用JDBC访问Hive元数据。 I have added all the jar files required in the classpath. 我已经添加了类路径中所需的所有jar文件。 I was following the tutorial from here- https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC 我从这里开始关注本教程-https https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC //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. 添加所有jar文件之后,我尝试编写一个示例程序以使用Java连接到Hive。 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. 我通过登录Putty并传递主机名来启动Hive服务器。

$ 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. Hive服务器本身并不安全。 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. 根据我的经验,最典型的配置是在与应用程序相同的框中启动Hive服务器,确保此框已连接到Hadoop群集并确保该框的安全。 This way your connection string is jdbc:hive://localhost:10000 and the security becomes not your headache, but a headache of your networking folks. 这样,您的连接字符串是jdbc:hive://localhost:10000 ,安全性不再是您的头疼,而是网络人员的头疼。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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