
41 total views, 0 views today
How to configure multiple Primavera database instance in Primavera P6 EPPM and access it in Primavera P6 API
In my previous post, I have explained How to configure the different Database in Primavera P6 and access in P6 Web. This is the continuation of the previous post but here we are going to access this multiple Database Instance in Primavera P6 API.
Below I configured Oracle database & Microsoft SQL Server database instance in my P6 admin config.
Below is the Primavera P6 API code that accesses the above two database instance and prints all the projects on each database instance.
package com.catgovind; import com.primavera.ServerException; import com.primavera.common.value.ObjectId; import com.primavera.integration.client.EnterpriseLoadManager; import com.primavera.integration.client.RMIURL; import com.primavera.integration.client.Session; import com.primavera.integration.client.bo.BOIterator; import com.primavera.integration.client.bo.object.Project; import com.primavera.integration.common.DatabaseInstance; public class Main { static{ System.setProperty("primavera.bootstrap.home","C:\\P6EPPM_172\\p6"); } public static void main(String[] args) { //P6 Application admin username and password for Oracle Database String username="admin"; String password="admin"; //P6 Application admin username and password for SQL SERVER Database String username1="admin"; String password1="admin123"; try{ //Connect to P6 usiing Local Mode DatabaseInstance[] dbInstances = Session.getDatabaseInstances( RMIURL.getRmiUrl( RMIURL.LOCAL_SERVICE ) ); int size = dbInstances.length; //SQL Server DB Instance DatabaseInstance SQL_SERVER_Instance = null; //Oracle Server DB Instance DatabaseInstance ORACLE_Instance = null; for(int i=0;iSQL_SERVER_PROJECTS = SQL_SERVER_session.getEnterpriseLoadManager().loadProjects(new String[]{"Name","Id"}, null, null); while(SQL_SERVER_PROJECTS.hasNext()){ Project proj = SQL_SERVER_PROJECTS.next(); System.out.println(proj.getId()+" || "+proj.getName()); } //Retrieve Oracle Database Instance Session ORACLE_session = Session.login( RMIURL.getRmiUrl( RMIURL.LOCAL_SERVICE ),ORACLE_Instance.getDatabaseId(), username,password ); BOIterator ORACLE_PROJECTS = ORACLE_session.getEnterpriseLoadManager().loadProjects(new String[]{"Name","Id"}, null, null); while(ORACLE_PROJECTS.hasNext()){ Project proj = ORACLE_PROJECTS.next(); System.out.println(proj.getId()+" || "+proj.getName()); } } catch(Exception e){ e.printStackTrace(); } } }
Output:-
jdbc:oracle:thin:@localhost:1521:orcl
jdbc:sqlserver://localhost:1433;database=PMDB;
Project_SQL_SERVER || Project_SQL_Server
Project_Oracle || Project_Oracle
This post first appeared on Oracle ADF, BPM, BI And Primavera P6 Tutorials, please read the originial post: here