整理的相關(guān)資料
集成和擴(kuò)展Kettle的文檔
官方例子
API
官方wiki
一些常用的實(shí)例
- 連接資源庫(kù)
KettleEnvironment.init();
//DatabaseMeta(String name,String type,String access,String host,String db,String port,String user,String pass)
DatabaseMeta databaseMeta = new DatabaseMeta( "kettle", "Oracle", DatabaseMeta.dbAccessTypeCode[0] , url, dbName, port, dbUserName, dbPassword );
RepositoryMeta repositoryMeta =
new KettleDatabaseRepositoryMeta( "KettleDatabaseRepository", "Oracle", "Oracle Repository", databaseMeta );
PluginRegistry registry = PluginRegistry.getInstance();
Repository repository = registry.loadClass(
RepositoryPluginType.class,
repositoryMeta,
Repository.class
);
repository.init(repositoryMeta);
repository.disconnect();
repository.connect(kettleUserName, kettlePassword);
- JOB運(yùn)行
JobMeta jobMeta = kettleRepository.loadJob(new LongObjectId(jobId), null);
Job job = new Job(kettleRepository,jobMeta);
job.setLogLevel(LogLevel.BASIC);
job.start();
job.waitUntilFinished();
- TRANS運(yùn)行
TransMeta transMeta = kettleRepository.loadTransformation(new LongObjectId(transId), null);
Trans trans = new Trans(transMeta);
trans.execute(null);
trans.waitUntilFinished();
- 獲取運(yùn)行日志
//run trans
...
//get result
Result result = trans.getResult();
String logText = KettleLogStore.getAppender().getBuffer( trans.getLogChannelId(), true ).toString();
//run job
...
//get result
Result result = job.getResult();
String logText = KettleLogStore.getAppender().getBuffer( job.getLogChannelId(), true ).toString();