===================================================================
希望能够和使用的DataStage 朋友们一起探讨学习。QQ:154642320 e-mail:zhaofmyan@sohu.com
===================================================================
昨天写了一篇关于通过命令行调用datastage job的博客。今天来补充一下关于如何通过java来调用datastage job.
package com.mphasis.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CallDSJob {
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
BufferedReader br=null;
String path = "C://Ascential//DataStage//Engine//bin//";//datastage 安装的路径
Process p = Runtime.getRuntime().exec(path+"/dsjob -run -mode NORMAL -wait -jobstatus sysup1_MPHASIS_1 Sequential");//输入要运行的命令
br=new BufferedReader(new InputStreamReader(p.getInputStream())); //获得命令的返回的信息
String line=null;
System.out.println("");
while((line=br.readLine())!=null){
System.out.println(line); //打印出返回的信息
}
p.waitFor();
System.out.println(p.exitValue());//如果执行成功则返回 0
p.destroy();//销毁该进程
}
}
控制台的输出:
Waiting for job...
Job Status : (1)
关于命令行的部分请参考