2017-09-13 145 views
0

我正在嘗試使用jlmapi從java運行Informatica工作流程。但由於出現錯誤,我無法建立連接。這是我的代碼: -在Java中執行informatica工作流程

public class executeWorkflow { 

    public static void main(String[] args) { 
     // TODO Auto-generated method stub 
     IJLMDriver ld = null; 
     IJLMConnection connection = null; 

     try { 
      ld = DriverFactory.getDriver("JLMDriver10"); 
     } catch (JLMException e) { 
      e.printStackTrace(); 
     } 
     try { 
      ld.initialize("C:\\ExecuteWorkflow_WIN64_v1\\lib\\lib\\locale"); 
     } catch (JLMException e1) { 

      e1.printStackTrace(); 
     } 
     try { 
      connection = ld.getConnection("domain_name",6005,180,null); 
     } catch (JLMException e1) { 
      e1.printStackTrace(); 
     } 
     try { 
      connection.login("","Repository","admin","pwd",null); 
     } catch (JLMException e1) { 
      e1.printStackTrace(); 
     } 
     IJLMServerDetails srvdetails = null; 
     try { 
     srvdetails =connection.getServerDetails(EJLMMonitorServerMode.ALL,null); 
     } catch (JLMException e) { 
      e.printStackTrace(); 
     } 
     System.out.println("Server Status: "+srvdetails.getStatus().toString()); 
     IJLMWorkflowDetails[] workflow = srvdetails.getWorkflows(); 
     System.out.println("Number of Workflows: " + workflow.length); 
    } 

} 

我收到以下錯誤:

Error Code: -109 Error Message: Unable to establish connection with Informatica Server Message Context: IJLMDriver::getConnection(domain,6005,180) 
    at com.informatica.powercenter.sdk.lm.JLMException.handleExceptionOrWarning(JLMException.java:545) 
    at com.informatica.powercenter.sdk.lm.JLMDriver10.getConnection(JLMDriver10.java:197) 
    at informatica.executeWorkflow.main(executeWorkflow.java:93) 
Exception in thread "main" java.lang.NullPointerException 
    at informatica.executeWorkflow.main(executeWorkflow.java:99) 

我做錯了嗎?以及getConnection參數中的端口號180附近是什麼?

回答

0

上述代碼不起作用,因爲Informatica版本的API從10開始。這是9.6.1,因此與API不兼容。這是一個解決方法。您可以使用pmcmd.batch文件運行工作流程。你可以從你的java代碼中調用.exe文件。我也曾問過這個問題。你可以在這裏找到代碼 - Running pmcmd from java