Get the list of all the DB connections present in the Intellicus Repository
This Java API is used to get the list of all the DB connections present in the Intellicus Repository.
Refer to <Intellicus_Install_Path>/SampleCodes/Java APIs/DBConnection Mangement/GetDBConnectionList.java for sample code of this use case.
Steps:
- Initialize Report Client.
- Initialize Requestor UserInfo.
- Create a Layout Manager class object for report layout management related operations
LayoutManager lm = new LayoutManager();
- Get the list of All Database Connections.
Method : getDBConnectionListpublic java.util.HashMap getDBConnectionList(UserInfo userInfo)
throws LayoutHandlerException
This method returns the list of report engine to database connection names.
Parameters:
- UserInfo: UserInfo For authorization.
Returns:
HashMap of Database Connection names and Driver details as ArrayList.
HashMap map=lm.getDBConnectionList(requestorUserInfo);
Create DB Connection in the Intellicus Repository
This Java API is used to create a new Database Connection in the Intellicus Repository.
Refer to <Intellicus_Install_Path>/SampleCodes/Java APIs/DBConnection Mangement/CreateDBConnection.java for sample code of this use case.
Steps:
- Initialize Report Client.
- Initialize Requestor UserInfo.
- Create a Layout Manager class object for report layout management related operations
LayoutManager lm = new LayoutManager();
- Set url for DBDriver.
DBDriver driverDB = new DBDriver();
//Making an object of hashmap for DBDriver
HashMap hMap = new HashMap();
String server = “192.168.33.52″;
String provider = “MSSQL”;
String port = “1433”;
String database = “M90”;
String driverVersion = “2005”;
driverDB.setUrl(“jdbc:sqlserver://192.168.33.52:1433;databaseName=M90;selectMethod=cursor;user=sa;password=intellicus”);
driverDB.setProvider(provider);
hMap.put(“SERVER”, server);
hMap.put(“PORT”, port);
hMap.put(“DATABASE”,dataBase);
hMap.put(“DRIVERVERSION”,driverVersion);
driverDB.setAttrHash(hMap);
- Create an instance of DB Connection and set related properties
String userId = “sa”;
String passwrd = “123456”;
String connName = “MyConnection”;
//Making an object of DBConnection
DBConnection dbConn = new DBConnection();
dbConn.setDbDriver(driverDB);
dbConn.setUserId(userId);
dbConn.setPassword(passwrd);
dbConn.setConnectionName(connName);
- Add DB Connection to Report Server.
Method : addReportServerConnectionpublic java.lang.String addReportServerConnection
(DBConnection dbConnection, UserInfo userInfo)
throws LayoutHandlerException
This method adds a new Report Server Connection in the Repository.
Parameters:
- DbConnection: DBConnection object which needs to be added.
- UserInfo: The UserInfo object.
Returns:
- String: The status of operation returned by the Report Engine
lm.addReportServerConnection(dbConn, requestorUserInfo);
Create DB Connection for File Data Source
This Java API is used to create a new Database Connection in the Intellicus Repository for File Type Data Source.
Refer to <Intellicus_Install_Path>/SampleCodes/Java APIs/DBConnection Mangement/CreateDBConnectionFromFileSource.java for sample code of this use case.
Steps:
- Initialize Report Client.
- Initialize Requestor UserInfo.
- Create a Layout Manager class object for report layout management related operations
LayoutManager lm = new LayoutManager();
- Set url for DBDriver.
DBDriver driverDB = new DBDriver();
//Making an object of hashmap for DBDriver
HashMap hMap = new HashMap();
driverDB.setUrl(“jdbc:FS:////192.168.33.93/FilesForConnection/csv”);
driverDB.setProvider(“FILES”);
//set driver type
hMap.put(“DRIVERTYPE”,”NETWORK_PATH”);
driverDB.setAttrHash(hMap);
- Create an instance of DB Connection and set related properties
String connName = “FileConnection”;
//Making an object of DBConnection
DBConnection dbConn = new DBConnection();
dbConn.setDbDriver(driverDB);
dbConn.setConnectionName(connName);
//set username
dbConn.setUserId(“UserID”);
//set password
dbConn.setPassword(“pwd123”);
//set Initial Connections
dbConn.setInitialConnections(“2”);
//Set incremental size
dbConn.setIncrementSize(“4”);
//Set Maximum number of Connections
dbConn.setMaxConnections(“8”);
//Set true for Read Only Connection or else set false
dbConn.setIsReadOnly(false);
//Set true to set it as Default Connection
dbConn.setIsDefault(false);
//To enable/disable Metadata Cache for the Connection
dbConn.setMetaDataCacheEnabled(true);
- Add DB Connection to Report Server.
Method : addReportServerConnectionpublic java.lang.String addReportServerConnection
(DBConnection dbConnection, UserInfo userInfo)
throws LayoutHandlerException
This method adds a new Report Server Connection in the Repository.
Parameters:
- DbConnection: DBConnection object which needs to be added.
- UserInfo: The UserInfo object.
Returns:
- String: The status of operation returned by the Report Engine
lm.addReportServerConnection(dbConn, requestorUserInfo);
Delete DB Connection from the Intellicus Repository
This Java API is used to delete an existing Database Connection in the Intellicus Repository.
Refer to <Intellicus_Install_Path>/SampleCodes/Java APIs/DBConnection Mangement/DeleteDBConnection.java for sample code of this use case.
Steps:
- Initialize Report Client.
- Initialize Requestor UserInfo.
- Create a Layout Manager class object for report layout management related operations
LayoutManager lm = new LayoutManager();
- Get the DB Connection list and iterate through each element of list so as to get the given connection i.e. to be deleted. If the connection exists, then delete it.
Method: deleteReportServerConnection
public java.lang.String deleteReportServerConnection
(DBConnection dbConnection, UserInfo userInfo)
throws LayoutHandlerException
This method deletes the given report server connection from the repository.
Parameters:
- DbConnection: DBConnection object which needs to be deleted.
- UserInfo: The UserInfo object.
Returns:
- String: The status of operation returned by the Report Engine.
Part of Sample Code implementing “deleteReportServerConnection”:
map=lm.getDBConnectionList(requestorUserInfo); Set s=map.keySet(); Iterator itr=s.iterator(); while(itr.hasNext()) { ArrayList l=(ArrayList)(map.get(itr.next())); //Iterating through the List for(int i=0;i<l.size();i++) { Object o=l.get(i); if("class com.intellica.client.common.DBConnection" .equalsIgnoreCase(String.valueOf(o.getClass()))) { DBConnection dbConn=(DBConnection)l.get(i); // Check whether the Connection exists or not if(connectionName.equalsIgnoreCase (dbConn.getConnectionName())) { try { //The method delete given Report Server Connection lmanager.deleteReportServerConnection(dbConn, requestorUserInfo); }catch(LayoutHandlerException lhException) { lhException.printStackTrace(); } }//end inner if }//end Outer if }//end for }//end while