GalaxyPilot —— D.S


                  生命不熄,戰斗不止
          數據加載中……

          java調用kettle4.2數據庫型資料庫中的作業

          import org.pentaho.di.core.KettleEnvironment;
          import org.pentaho.di.core.database.DatabaseMeta;
          import org.pentaho.di.job.JobMeta;
          import org.pentaho.di.job.Job;
          import org.pentaho.di.repository.Repository;
          import org.pentaho.di.repository.RepositoryDirectoryInterface;
          import org.pentaho.di.repository.kdr.KettleDatabaseRepository;
          import org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta;

          public class execRepositoryJobs {

              private static String jobName = "Job";

              public static void main(String[] args) {
                  try {
                      KettleEnvironment.init();

                      KettleDatabaseRepository repository = new KettleDatabaseRepository();

                      DatabaseMeta databaseMeta = new DatabaseMeta("repository", "MSSQL","Native", "192.169.0.146", "repository", "1433", "sa","sa");

                      KettleDatabaseRepositoryMeta kettleDatabaseMeta = new KettleDatabaseRepositoryMeta("repository", "ERP", "Transformation description",databaseMeta);

                      repository.init(kettleDatabaseMeta);

                      repository.connect("admin", "admin");

                      RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree();
                      
                      JobMeta jobMeta = ((Repository) repository).loadJob(jobName, directory, null, null ) ;

          //            RepositoryDirectoryInterface fooBar = directory.findDirectory("/");
          //
          //            JobMeta jobMeta = repository.loadJob(repository.getJobId(jobName, fooBar), null);

                      Job job = new Job(repository,jobMeta);
                      
                      job.start();
                      
                      job.waitUntilFinished();
                      
                      if (job.getErrors() > 0) {
                          throw new RuntimeException(
                                  "There were errors during transformation execution.");
                      }

                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }

          posted on 2012-07-30 14:33 舵手 閱讀(1519) 評論(1)  編輯  收藏

          評論

          # re: java調用kettle4.2數據庫型資料庫中的作業  回復  更多評論   

          這陣子跟kettle較勁了?
          2012-10-25 11:19 | klzz

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 财经| 张掖市| 五寨县| 聊城市| 赣榆县| 白沙| 五原县| 息烽县| 金秀| 云南省| 合川市| 金寨县| 启东市| 临朐县| 原平市| 陇南市| 旌德县| 疏附县| 安岳县| 五寨县| 谢通门县| 老河口市| 武平县| 堆龙德庆县| 三门峡市| 顺平县| 砚山县| 临潭县| 隆化县| 辽中县| 齐齐哈尔市| 丰顺县| 故城县| 娱乐| 额敏县| 文安县| 夏河县| 东源县| 新密市| 抚松县| 南和县|