2013-10-03 35 views

回答

-1

我試試這個來執行轉換this way。 Kettle的Java API非常易讀。

上述方法不包括檢索結果。您需要添加一些自定義邏輯來讀取作業的輸出數據。我不確定是否有通用的方式來使用ETL。

您可以嘗試將輸出抓取到HSQLDB或其他內存數據庫,如here所述,並手動提取輸出。

+2

請仔細閱讀[是什麼讓一個很好的答案(http://stackoverflow.com/help/how-to-answer)就好像您提供的任何鏈接都無法訪問,您的答案就變得毫無用處。 –

1

雖然從Java執行命令可能並不理想,但下面的內容會起作用。只需用適當的路徑替換cmd行並讀入作業的輸出文件即可。

public static void main(String[] args) { 

    try { 
     String cmd = "\"c:\\Program Files\\Pentaho\\pdi-ce-5.0.1.A-stable\\data-integration\\kitchen.bat\" -file=\"c:\\users\\exampleuser\\desktop\\examplejob.kjb\""; 
     System.out.println(cmd); 
     Process process = Runtime.getRuntime().exec(cmd); 
     process.waitFor(); 
    } catch (Exception e) { 
     e.printStackTrace(System.err); 
    } 
    /*READ OUTPUT FILE OF KJB IN TO OBTAIN VALUES*/ 


} 

* http://forums.pentaho.com/showthread.php?81151-Tutorial-Using-command-line-arguments-with-Kettle-and-scheduling * http://docs.oracle.com/javase/tutorial/java/data/strings.html * http://wiki.pentaho.com/display/EAI/.01+Introduction+to+Spoon * http://javarevisited.blogspot.com/2011/02/how-to-execute-native-shell-commands.html * http://www.mkyong.com/java/how-to-execute-shell-command-from-java/

相關問題