hiveserver2 启动后jdbc 连接上的原因
来源:互联网 发布:买网络电话卡被骗 编辑:程序博客网 时间:2024/05/16 14:47
1 首先修改 hive-site.xml
<property> <name>hive.server2.thrift.port</name> <value>10000</value></property><property> <name>hive.server2.thrift.bind.host</name> <value>localhost</value> <!-- 默认是localhost,但我手动改成了本机的ip地址,很可能就是我改了这个才起作用的 --></property>
2 启动hiveserver2
$HIVE_HOME/bin/hive --service hiveserver2
3 测试连接是否以连上
不用写jdbc程序,运行 bin/beeline.sh
然后输入 !connect jdbc:hive2://上面设置的ip地址:10000 hiveuser hiveuser 后面两个是你创建的用户名和密码
如果能连接上就表示 jdbc没有问题了
注: !connect jdbc:hive2://localhost:10000 hiveuser hiveuser 这里不要使用localhost,应该使用配置的ip
4 通过程序连接jdbc
也可以通过自己写程序连接jdbc
package test;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;// import org.apache.hive.jdbc.HiveDriver;public class HiveJdbcClient {private static String driverName = "org.apache.hive.jdbc.HiveDriver";public boolean run() {try {Class.forName(driverName);Connection con = null;con = DriverManager.getConnection("jdbc:hive2://192.168.17.15:10000/hivedb", "hiveuser", "hiveuser");Statement stmt = con.createStatement();ResultSet res = null;String sql = "select count(*) from test_data";System.out.println("Running: " + sql);res = stmt.executeQuery(sql);System.out.println("ok");while (res.next()) {System.out.println(res.getString(1));}return true;} catch (Exception e) {e.printStackTrace();System.out.println("error");return false;}}public static void main(String[] args) throws SQLException {HiveJdbcClient hiveJdbcClient = new HiveJdbcClient();hiveJdbcClient.run();}}
参考的url为:http://www.tuicool.com/articles/Bbqaea
1 0
- hiveserver2 启动后jdbc 连接上的原因
- jdbc远程连接hiveserver2
- JDBC远程连接hiveserver2
- jdbc远程连接hiveserver2
- mssql2000 数据库 JDBC连接不上的原因
- java jdbc 连接hive cdh4.2 hiveserver2
- Hive中文乱码(JDBC连接HiveServer2)问题解决
- java jdbc 连接hive cdh4.2 hiveserver2
- Java代码通过JDBC连接Hiveserver2
- 用Java代码通过JDBC连接Hiveserver2
- [解决] HiveServer2中使用jdbc访问hbase时导致ZooKeeper连接持续增加的解决
- Eclipse JDBC连接Hive 两种方法 hiveserver hiveserver2
- PLSQL连接不上,配置tnsnames.ora后连接失败的可能原因
- Eclipse luna启动后立马就卡死的一种原因及解决办法(HotSpot虚拟机上)
- linux服务器上cloudera:cdh5.8使用python连接hiveServer2
- MySql安装后启动不成功的原因
- HiveServer2与beeline的使用 & Hive JDBC编程
- mongod连接不上的原因
- 《计算机网络 自顶向下方法》读书笔记(一)
- [我的翻译]代码审查过程
- virtualbox中ubuntu和windows共享文件夹设置
- 判断某年是否为闰年
- 15年3月份
- hiveserver2 启动后jdbc 连接上的原因
- #296 --- C ( set可以这么好用)
- 启动jar文件bat脚本
- .net framework无法安装 (权限问题解决办法)
- 长方柱类
- 第1周项目1-阅读程序
- 滑冰场造价
- 开始菜单变透明 Windows 10新镜像泄露
- 同步(Synchronization)