2013-07-26 77 views
2

我正在嘗試使用Java API與informatica連接。我打算在位置 C:\ Program Files \ Informatica \ PowerCenter8.6.1 \ MappingSDK \ samples \ src \ com \ informatica \ powercenter \ sdk \ mapfwk \ samples中使用com.informatica.powercenter.sdk.mapfwk.core.*庫運行示例。Informatica的Java API

當我嘗試運行CreateConnectionSample.java(簡單連接到存儲庫)時,我收到異常。

代碼:

CachedRepositoryConnectionManager rpMgr = new CachedRepositoryConnectionManager(
      new PmrepRepositoryConnectionManager()); 
    Repository rep = new Repository(); 
    RepoProperties repoProp = new RepoProperties(); 

    repoProp.setProperty(RepoPropsConstant.PC_CLIENT_INSTALL_PATH, 
      "C:\\Program Files\\Informatica\\PowerCenter8.6.1\\client\\bin"); 
    repoProp.setProperty(RepoPropsConstant.TARGET_REPO_NAME, "EDW_DEV_REPO"); 
    repoProp.setProperty(RepoPropsConstant.REPO_SERVER_DOMAIN_NAME, "DOM_GWM_DEV01"); 
    repoProp.setProperty(RepoPropsConstant.SECURITY_DOMAIN, "MSSB_INFA_DVLPR_DEV"); 
    repoProp.setProperty(RepoPropsConstant.ADMIN_USERNAME, "Username"); 
    repoProp.setProperty(RepoPropsConstant.ADMIN_PASSWORD, "Password"); 
    repoProp.setProperty(RepoPropsConstant.TARGET_FOLDER_NAME,"CORE"); 
    rep.setProperties(repoProp); 
    rep.setRepositoryConnectionManager(rpMgr); 
    ConnectionObject connObj = new ConnectionObject("Con", ConnectionAttributes.CONN_TYPE_RELATION); 
    rep.createConnection(connObj); 

我得到異常

com.informatica.powercenter.sdk.mapfwk.exceptions.ConnectionFailedException: Failed to list connections in PowerCenter Repository 

有沒有人這樣做早些時候?任何人都可以幫助我設置Java API。

回答

2

嗯,這真的很舊,希望你最終能夠通過SDK進行連接。以下是我最近編寫的一些代碼,用於獲取連接並查詢有關工作流程的一些內容。

public static void main(String[] args) throws Exception { 
    if(System.getenv("INFA_DOMAINS_FILE") == null)     // make sure .infa file exists 
     throw new Exception("INFA_DOMAINS_FILE path not set in environment variables."); 

    Repository rep = new Repository(); 
    RepoConnectionInfo rci = new RepoConnectionInfo(); 
    rci.setRepoServerHost("your host DNS name");     // set host URI  
    rci.setRepoServerPort("your host port number");         // host port 
    rci.setRepoServerDomainName("your-domain-name");     // repository domain name 
    rci.setTargetRepoName("your-repository");       // repository 
    rci.setSecurityDomain("e-directory");       // security type 
    rci.setAdminUsername("your-credentials");        // uid 
    rci.setAdminPassword(getPassword());       // pwd (stored in environment variable -- encoded so it's not cleartext) 
    rci.setPmrepCacheFolder("c:\\users\\your-credentials\\Informatica\\"); // some cache folder that must be set 
    rci.setPcClientInstallPath("C:\\Informatica\\9.0.1\\clients\\PowerCenterClient\\client\\bin\\"); 
    rep.setRepoConnectionInfo(rci);             // provide connection info to rep object 
    RepositoryConnectionManager repmgr = new PmrepRepositoryConnectionManager(); // set up repository connection manager 
    rep.setRepositoryConnectionManager(repmgr);          // tell repository to use connection manager 

    System.out.println("Folders:"); 
    System.out.println("==========================================================================="); 
    List<Folder> folders = rep.getFolders(); 
    for(Folder f: folders) { System.out.println(f);} 
} 
+0

我個人認爲他們在SDK文檔中提供的示例是毫無價值的。他們忽視了重要的細節,他們沒有解釋如何實際獲得連接性,其中一些是用Groovy編寫的(呃......我們選擇一種語言並只使用一種?)。 我的印象(通過觀察在INFO級別設置根記錄器運行的代碼),這個SDK實際上只是在操縱一些可執行文件(如pmrep.exe)並從中收集數據,所以它實際上是一種巨大的黑客攻擊。這就像回到JDBC Type 1驅動程序......可能更糟。 – Calphool