![]() |
很拉风的小狗 · 使用 API for Cassandra ...· 10 月前 · |
![]() |
不羁的风衣 · WPF中Button点击后闪烁的解决办法_b ...· 1 年前 · |
![]() |
绅士的茴香 · Android蓝牙Gatt连接 - 掘金· 1 年前 · |
![]() |
高大的毛衣 · 克里金插值的定义----普通克里金插值算法_ ...· 1 年前 · |
![]() |
拉风的眼镜 · python - ...· 2 年前 · |
本文为您介绍在 E-MapReduce 集群提交 Hive SQL 的三种方式。
su hive
hive
返回信息如下所示时,表示进入 Hive 命令行
Hive Session ID = aaa9c23d-4975-4c10-bb9a-1817c5fa36e6
Logging initialized using configuration in file:/etc/emr/hive/conf/hive-log4j2.properties Async: true
Hive Session ID = 258437d2-f601-42c9-bab3-731b975b0642
使用 beeline 命令
beeline -u "jdbc:hive2://<HiveServer2地址>:10000/" -n <username> -p <password>
说明
输入密码后,会得到信息:
Connecting to jdbc:hive2://<HiveServer2地址>:10000/
Connected to: Apache Hive (version 3.1.3-ve-2)
Driver: Hive JDBC (version 3.1.3-ve-2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.3-ve-2 by Apache Hive
0: jdbc:hive2://<HiveServer2地址>:10000/>
表示已成功连接到 Hive。
mvn archetype:generate -DgroupId=com.example -DartifactId=hivejdbc -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
<dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>3.1.2</version> </dependency>
package com.example;
import java.sql.*;
* Hello world!
public class App
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
// LDAP 中的用户名
String user = "hive";
// LDAP 中的用户密码,
String password = "*******";
Connection con = DriverManager.getConnection(
"jdbc:hive2://<HiveServer2地址>:10000", user, password);
Statement stmt = con.createStatement();
String sql = "show databases";
ResultSet res = stmt.executeQuery(sql);
while (res.next()) {
System.out.println(res.getString(1));
![]() |
绅士的茴香 · Android蓝牙Gatt连接 - 掘金 1 年前 |