kettle 创建资源库 Java api DatabaseRepository

创建资源库

前置
  • mysql
  • 数据库 test

核心代码

   KettleEnvironment.init();


        DatabaseMeta databaseMeta = new DatabaseMeta("test-db", "MYSQL", "Native", "localhost",
                "test1", "3306", "root", "toor@1234");
        // 关闭mysql推荐SSL连接提示
        databaseMeta.addExtraOption("MYSQL", "useSSL", "false");
        repositoryMeta = new KettleDatabaseRepositoryMeta("test-repo", "test-repo", "test-repo", databaseMeta);
        repository = new KettleDatabaseRepository();
        repository.init(repositoryMeta);

        repository.connectionDelegate.connect(true, true);
        KettleDatabaseRepositoryCreationHelper helper = new KettleDatabaseRepositoryCreationHelper(repository);
        helper.createRepositorySchema(null, false, new ArrayList<>(), false);
        
        repository.connect("admin", "admin");
        assertTrue(repository.isConnected());
posted @ 2023-01-19 13:28  vx_guanchaoguo0  阅读(231)  评论(0编辑  收藏  举报