gpt4 book ai didi

hadoop - 如何在未安装的系统中使用 jar 文件运行 drill?

转载 作者:可可西里 更新时间:2023-11-01 16:42:19 27 4
gpt4 key购买 nike

我正在使用 Apache drill 1.8 制作程序。

我正在尝试在未安装 drill 的 HDFS 中运行该程序。

我认为的方法是使用jar文件,drill包含的jar文件可以运行这个程序,因为它是在虚拟机中运行的。

但我对这种方式没有信心。能行吗?

如果这种方式可行,如何在 jar 文件中包含 drill?

如果不是,那是什么方式?

还有一个问题,如何使用 Java 代码更改存储配置?

最佳答案

drill 或 hdfs 是否在同一台机器上运行并不重要。

为什么需要创建一个jar。

如果您使用 Maven 作为构建工具,请添加 Drill JDBC 驱动程序依赖项:

<dependency>
<groupId>org.apache.drill.exec</groupId>
<artifactId>drill-jdbc</artifactId>
<version>1.8.0</version>
</dependency>

示例代码:

public class TestJDBC {

// Host name of machine on which drill is running
public static final String DRILL_JDBC_LOCAL_URI = "jdbc:drill:drillbit=192.xxx.xxx.xxx";

public static final String JDBC_DRIVER = "org.apache.drill.jdbc.Driver";

public static void main(String[] args) throws SQLException {

try {
Class.forName(JDBC_DRIVER);

} catch (ClassNotFoundException ce) {
ce.printStackTrace();
}

try (Connection conn = new Driver().connect(DRILL_JDBC_LOCAL_URI, null);
Statement stmt = conn.createStatement();) {

String sql = "select employee_id,first_name,last_name from cp.`employee.json` limit 10";
ResultSet rs = stmt.executeQuery(sql);

while (rs.next()) {
System.out.print(rs.getInt("employee_id") + "\t");
System.out.print(rs.getString("first_name") + "\t");
System.out.print(rs.getString("last_name") + "\t");
System.out.println();
}
rs.close();

} catch (SQLException se) {
se.printStackTrace();
}
}
}

关于hadoop - 如何在未安装的系统中使用 jar 文件运行 drill?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39722441/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com