这是我的代码
public static void main(String [] args) {
try {
KettleEnvironment.init();
KettleDatabaseRepository repository = new KettleDatabaseRepository();
DatabaseMeta databaseMeta = new DatabaseMeta();
databaseMeta.setDatabaseType("PostgreSQL");
databaseMeta.setHostname("localhost");
databaseMeta.setDBName("pditest");
databaseMeta.setDBPort("5432");
databaseMeta.setUsername("postgres");
databaseMeta.setPassword("krisha");
KettleDatabaseRepositoryMeta kettleDatabaseMeta = new KettleDatabaseRepositoryMeta(
"repositoryId", "kettle-repo", "Transformation description", databaseMeta );
repository.init( kettleDatabaseMeta );
repository.connect("admin","admin");
RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree();
TransMeta transformationMeta = repository.loadTransformation(
"testTransformation", directory, null, true, null ) ;
Trans trans = new Trans(transformationMeta);
trans.execute( null ); // You can pass arguments instead of null.
trans.waitUntilFinished();
if ( trans.getErrors() > 0 ) {
System.out.println("error in excecution ");
}else{
//Transformation run successfully.
System.out.println("transfromation run successfully");
}
}
catch (KettleException e)
{
e.printStackTrace();
}
}
}
但出现错误: org.pentaho.di.core.exception.KettleAuthException: 密码或登录名不正确
at org.pentaho.di.repository.kdr.delegates.KettleDatabaseRepositoryUserDelegate.loadUserInfo(KettleDatabaseRepositoryUserDelegate.java:109)
at org.pentaho.di.repository.kdr.KettleDatabaseRepository.connect(KettleDatabaseRepository.java:196)
at org.pentaho.di.repository.kdr.KettleDatabaseRepository.connect(KettleDatabaseRepository.java:180)
at abc.PDIDatabase.main(PDIDatabase.java:31)
我也用相同的用户名,密码“ admin”,“ admin”测试了勺子中的连接