java程序中给Kettle传参数

import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.logging.LogWriter;
import org.pentaho.di.core.util.EnvUtil;
import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobEntryLoader;
import org.pentaho.di.job.JobMeta;
import org.pentaho.di.trans.StepLoader;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;


public class EtlParams {


public static void main(String[] args) {
// TODO Auto-generated method stub
runJob("D:\\etl\\params1.kjb");
}
public static void runJob(String filename) {
try {
StepLoader.init();
EnvUtil.environmentInit();
JobEntryLoader.init();
JobMeta jobMeta = new JobMeta(LogWriter.getInstance(),filename,null);
Job job = new Job(LogWriter.getInstance(),StepLoader.getInstance() ,null,jobMeta);
job.getJobMeta().setInternalKettleVariables(job);
job.setVariable("XMLPATH", "D:\\etl\\gz_zb_zb");
job.setVariable("ZB_FJD", "23d267b7aad54f5b961f66fac791b356");
job.execute(); // You can pass arguments instead of null.
job.waitUntilFinished();
if ( job.getErrors() > 0 )
{
throw new RuntimeException( "There were errors during transformation execution." );
}
}
catch ( KettleException e ) {
System.out.println(e);
}
}

}

job里,在需要调用的地方直接${变量名},调用就可以了

阅读更多
个人分类: java
上一篇Java程序调用kettle中的job及trans
下一篇java应用程序中集成Kettle
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭