kettle官方上提供的例子是kettle4.0以前的代码。
1、引人jar包
2、用kettle的spoon建trans
3、java执行本地trans方法
public static void doTrans() throws KettleException{
KettleEnvironment.init();
TransMeta transMeta = new TransMeta("D:\\temp\\tr_test.ktr");
Trans trans = new Trans(transMeta);
trans.execute(null);
trans.waitUntilFinished();
}
4、测试
public static void main(String[] args) throws KettleException {
doTrans()
}
5、建job
6、java执行本地job方法
public static void doJobs()throws KettleException{
// 初始化
KettleEnvironment.init();
// 日志
LogWriter log = LogWriter.getInstance("TransTest.log", true);
// job元对象
JobMeta jobMeta = new JobMeta("D:\\temp\\job_test.kjb", null);
Job job = new Job(null, jobMeta);
job.start();
job.waitUntilFinished();
}
7、测试
public static void main(String[] args) throws KettleException {
doJobs();
}