使用save 保存
public static void runTrans(String transName,KettleDatabaseRepository repository) {
try {
RepositoryDirectoryInterface dir = repository.loadRepositoryDirectoryTree().findDirectory("/");
ObjectId objectId = repository.getTransformationID(transName, dir);
TransMeta transMeta = null;
if (objectId == null) {
transMeta = buildTrans(transName, repository);
repository.save(transMeta, "");
}else{
transMeta = repository.loadTransformation(objectId, null);
}
Trans trans = new Trans(transMeta);
trans.execute(null);
trans.waitUntilFinished();
if (trans.getErrors() > 0) {[]()
throw new RuntimeException("There were errors during transformation execution.");
}
System.out.println("***********the end************");
} catch (Exception e) {
e.printStackTrace();
}
}
- 运行正常
第二次报错
- 查询后发现 也有类似的问题
处理方式
-
kettle gui 选选项添加 characterEncoding=utf8
-
代码添加如下