2016-09-27 80 views
0

我正在使用Apache drill 1.8製作程序。如何使用jar文件在未安裝的系統中運行鑽取?

我試圖在非鑽鑽安裝的HDFS中運行這個程序。

我認爲使用jar文件的方式,包含的jar文件可以運行該程序,因爲它運行在虛擬機中。

但是我對此沒有信心。它可以工作嗎?

如果這種方式起作用,如何在jar文件中包含鑽取?

如果不是,是什麼樣的方式?

加問題,如何使用Java代碼更改存儲配置?

+0

如何使用訪問鑽 - JDBC,REST或任何其他方式? –

+0

我正在使用JDBC .. – jjj111144444

回答

1

在同一臺機器上運行的drill或hdfs無關緊要。

爲什麼你需要創建一個罐子。

如果您正在使用Maven作爲構建工具,加鑽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(); 
     } 
    } 
} 
相關問題