美文网首页
kettle-资料整理&代码示例

kettle-资料整理&代码示例

作者: vengo_mo | 来源:发表于2017-09-13 15:07 被阅读0次
    整理的相关资料

    集成和扩展Kettle的文档
    官方例子
    API
    官方wiki

    一些常用的实例
    1. 连接资源库
    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);
    
    1. JOB运行
    JobMeta jobMeta = kettleRepository.loadJob(new LongObjectId(jobId), null);
    Job job =  new Job(kettleRepository,jobMeta);
    job.setLogLevel(LogLevel.BASIC);
    job.start();
    job.waitUntilFinished();
    
    1. TRANS运行
    TransMeta transMeta = kettleRepository.loadTransformation(new LongObjectId(transId), null);
    Trans trans = new Trans(transMeta);
    trans.execute(null);
    trans.waitUntilFinished();
    
    1. 获取运行日志
    //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();
    

    相关文章

      网友评论

          本文标题:kettle-资料整理&代码示例

          本文链接:https://www.haomeiwen.com/subject/ntzksxtx.html