从无到有系列之Hive-jdbc测试操作hive03
来源:互联网 发布:微信订餐软件 编辑:程序博客网 时间:2024/05/21 16:48
本文转载至:http://blog.csdn.net/wind520/article/details/44084953(有个别自己的修改)
注:这里的hive版本是1.2.0,所以用的hiveserver2,区别于hiveserver1,不要混淆使用
1:运行
命令行模式:
hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10001
服务模式:
hiveserver2 start
- [jifeng@feng01 conf]$ hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10001
- Starting HiveServer2
- 15/03/05 16:59:33 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect. Use hive.hmshandler.retry.* instead
2:权限问题
java jdbc连接报错:- Exception in thread "main" java.sql.SQLException: Error while compiling statement: FAILED: RuntimeException Cannot make directory: hdfs://feng01:9000/tmp/hive-jifeng/hive_2015-03-05_17-04-43_349_5945847416346775092-3
- at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:121)
- at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:109)
- at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:231)
- at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:355)
- at demo.test.Pretest.main(Pretest.java:28)
服务端也看到错误
- FAILED: RuntimeException Cannot make directory: hdfs://feng01:9000/tmp/hive-jifeng/hive_2015-03-05_17-04-43_349_5945847416346775092-3
修改后
3:For input string: "5000L"
JDBC连接报:
- Exception in thread "main" java.sql.SQLException: For input string: "5000L"
- at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:121)
- at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:109)
- at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:263)
- at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:355)
- at demo.test.Pretest.main(Pretest.java:28)
把hive-site.xml
这个配置文件里hive.server2.long.polling.timeout这个参数是5000L,改成5000
- [jifeng@feng01 conf]$ vi hive-site.xml
- <name>hive.server2.long.polling.timeout</name>
- <value>5000</value>
- <description>Time in milliseconds that HiveServer2 will wait, before responding to asynchronous calls that
- use long polling</description>
- </property>
- package demo.test;
- import java.sql.*;
- public class Pretest {
- public static void main( String args[] )
- throws SQLException , ClassNotFoundException {
- String jdbcdriver="org.apache.hive.jdbc.HiveDriver";
- String jdbcurl="jdbc:hive2://localhost:10001";
- String username="hive";
- String password="hive";
- Class.forName(jdbcdriver);
- Connection c = DriverManager.getConnection(jdbcurl,username,password);
- Statement st = c.createStatement();
- // select * from firewall where idauto=16600918"));//
- print( "num should be 1 " , st.executeQuery("select * from test"));
- //( "select id,name,vip from users order by id limit 5" ) );
- // TODO indexing
- }
- static void print( String name , ResultSet res )
- throws SQLException {
- System.out.println( name);
- ResultSetMetaData meta=res.getMetaData();
- //System.out.println( "\t"+res.getRow()+"条记录");
- String str="";
- for(int i=1;i<=meta.getColumnCount();i++){
- str+=meta.getColumnName(i)+" ";
- //System.out.println( meta.getColumnName(i)+" ");
- }
- System.out.println("\t"+str);
- str="";
- while ( res.next() ){
- for(int i=1;i<=meta.getColumnCount();i++){
- str+= res.getString(i)+" "; }
- System.out.println("\t"+str);
- str="";
- }
- }
- }
运行结果: num should be 1
test.name
wangjian
0 0
- 从无到有系列之Hive-jdbc测试操作hive03
- 从无到有系列之Hive-入门操作及简单应用02
- 从无到有系列之Hive-安装部署01
- 从无到有系列之Hive-内建操作符及函数开发hive04
- 从无到有系列之Hive-hive全实战hive05
- 从无到有系列之HBase-入门操作02
- Hive之JDBC操作
- 从无到有系列之zookeeper-安装部署01
- 从无到有系列之HBase-安装部署01
- 从无到有系列之storm-安装部署01
- 从无到有系列之spark-安装部署01
- 从无到有系列之zeepelin-安装部署01
- 从无到有系列之zeepelin-小试牛刀02
- 从无到有系列之flume-安装部署01
- 从无到有系列之kafka生产消费者demo02
- 从无到有系列之flume-kafka整合01
- JDBC操作hive
- Hive之Java操作jdbc以及脚本实现
- 平台上传的附件下载后打开为空白原因
- 使用mjrefresh遇到的坑爹bug
- Git 文件忽略
- Android Studio 快捷设置
- Android开源项目分类汇总(二) ActionBar;Menu
- 从无到有系列之Hive-jdbc测试操作hive03
- Postman 安装及使用入门教程
- DSP28335 ecap使用
- 自己总结的web前端知识体系大全【欢迎补充】
- 深入浅出UML类图
- C++ STL 容器、迭代器、适配器
- 对ByteArrayInputStream/ByteArrayOutputStream类的应用里的transform函数的复用
- MFC——10.网络编程基础
- Android开源项目分类汇总(三) ViewPager 、Gallery、GridView、ImageView、ProgressBar