hive java api 博客分类: hive hive
程序员文章站
2024-03-15 11:43:47
...
1.启动 hadoop
start-all.sh
2.启动hive
./hive --service hiveserver2
3.新建Java 工程
导入jar包
导入hive\lib目录下的hive-jdbc-1.2.0-standalone.jar
导入hadoop-2.7.1\share\hadoop\common下的hadoop-common-2.7.1.jar
4.编写jdbc代码执行
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection conn = DriverManager.getConnection("jdbc:hive2://192.168.242.101:10000/park","root","root");
Statement statement = conn.createStatement();
//statement.executeUpdate("create table x2xx (id int,name string)");
statement.close();
conn.close();
start-all.sh
2.启动hive
./hive --service hiveserver2
3.新建Java 工程
导入jar包
导入hive\lib目录下的hive-jdbc-1.2.0-standalone.jar
导入hadoop-2.7.1\share\hadoop\common下的hadoop-common-2.7.1.jar
4.编写jdbc代码执行
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection conn = DriverManager.getConnection("jdbc:hive2://192.168.242.101:10000/park","root","root");
Statement statement = conn.createStatement();
//statement.executeUpdate("create table x2xx (id int,name string)");
statement.close();
conn.close();
public class HiveJDBC { public static void main(String args[]) throws Exception{ Class.forName("org.apache.hive.jdbc.HiveDriver"); Connection conn = DriverManager.getConnection("jdbc:hive2://192.168.76.131:10000/park","root","zhangbiao"); PreparedStatement ps = conn.prepareStatement("select * from ext_student"); ResultSet rs = ps.executeQuery(); while(rs.next()){ System.out.println("id:"+rs.getString(1)+" name:"+rs.getString(2)); } rs.close(); ps.close(); conn.close(); } }
推荐阅读
-
hive java api 博客分类: hive hive
-
hive hiveconf 配置 博客分类: Hive hive
-
关于HIVE的小白经验 博客分类: hadoophive Hadoophive
-
[hive error] check the manual that corresponds to your MySQL server version for 博客分类: linuxhive hivelinuxerror
-
Hive 3.x 支持 ACID 增删改查 博客分类: 大数据 hive hadoop 大数据
-
Hive To Elasticsearch 博客分类: hadoopelasticsearchhive
-
hive-ha 安装 博客分类: linuxhive linuxhivehahadoophdfs
-
Hive 3.x 支持 ACID 增删改查 博客分类: 大数据 hive hadoop 大数据
-
Elasticsearch拆分java api生成restful json代码 博客分类: java;nosql;elasticsearch javanosqlelasticsearch
-
Elasticsearch拆分java api生成restful json代码 博客分类: java;nosql;elasticsearch javanosqlelasticsearch