使用 Presto jdbc 驱动程序在 Hive 中查询表 - 失败并出现 "Server refused connection" 错误
Query tables in Hive using Presto jdbc driver - Failed with "Server refused connection" error
我正在使用 Presto 查询 EMR 中的 Hive 表。我初始化了 presto 驱动程序并获得了连接,但是当我尝试对该连接执行查询时,出现错误:服务器拒绝连接:http://aws.address/v1/statement.
我需要在使用前设置 Hive/AWS 凭据吗?我该怎么做?
public void init() {
try {
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
if(connection == null)
connection = DriverManager.getConnection(url,username,password);
// url = "jdbc:presto://aws.address:8889/hive/default"
} catch (ClassNotFoundException | SQLException e) {
// TOD: handle exception
e.printStackTrace();
}
}
public void executeMyQuery() {
if(connection == null) {
connection = driver.getConnection();
}
ResultSet resultSet = null;
Statement stmt = connection.createStatement();
try {
resultSet = stmt.executeQuery(query);
} catch (Exception e) {
logger.error("Failed to execute query, with error: ",e);
} finally {
if(resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(stmt != null){
stmt.close();
}
}
}
我需要使用 'port forwarding' 命令 (ssh) 才能访问 AWS 中的 presto 驱动程序。
我正在使用 Presto 查询 EMR 中的 Hive 表。我初始化了 presto 驱动程序并获得了连接,但是当我尝试对该连接执行查询时,出现错误:服务器拒绝连接:http://aws.address/v1/statement.
我需要在使用前设置 Hive/AWS 凭据吗?我该怎么做?
public void init() {
try {
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
if(connection == null)
connection = DriverManager.getConnection(url,username,password);
// url = "jdbc:presto://aws.address:8889/hive/default"
} catch (ClassNotFoundException | SQLException e) {
// TOD: handle exception
e.printStackTrace();
}
}
public void executeMyQuery() {
if(connection == null) {
connection = driver.getConnection();
}
ResultSet resultSet = null;
Statement stmt = connection.createStatement();
try {
resultSet = stmt.executeQuery(query);
} catch (Exception e) {
logger.error("Failed to execute query, with error: ",e);
} finally {
if(resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(stmt != null){
stmt.close();
}
}
}
我需要使用 'port forwarding' 命令 (ssh) 才能访问 AWS 中的 presto 驱动程序。