Sunday, 17 June 2018

OIM API - How to Get OIM Database Connection through the OIM Client?

public void getDatabaseConnectionExample(){
    //get OIM Client
    OIMClient oimClient = getOIMConnection();
   
    //OIM Schema Database Client
    com.thortech.xl.dataaccess.tcDataProvider dbProvider = null;
   
    try{
        //Establish connection to OIM Schema
        XLClientSecurityAssociation.setClientHandle(oimClient);
        dbProvider = new com.thortech.xl.client.dataobj.tcDataBaseClient();

        String query = "select usr_login from usr";           
        com.thortech.xl.dataaccess.tcDataSet usersDataSet = new com.thortech.xl.dataaccess.tcDataSet();
        usersDataSet.setQuery(dbProvider, query);
        usersDataSet.executeQuery();

        int numRecords = usersDataSet.getTotalRowCount();
       
        //iterate through each record
        for(int i = 0; i < numRecords; i++){
            usersDataSet.goToRow(i);
            System.out.println("User Login :: " + usersDataSet.getString("USR_LOGIN"));
        }
    }
  
    catch(Exception e){
        System.out.println("Exception occured while getting user details" + e);
    }
    finally{
        if(dbProvider != null){
            try{
                dbProvider.close();
            } catch(Exception e) {
                System.out.println("Exception occured while closing connection" + e);
            }
        }
       
        XLClientSecurityAssociation.clearThreadLoginSession();  
    }
}


Happy Learning!!!

4 comments:

  1. I really liked your Information. Keep up the good work. E-commerce Marketing

    ReplyDelete
  2. I am trying to validate password against password policy using the code as below and I see below error. Can you advise on this

    code part :

    XLClientSecurityAssociation.setClientHandle(oimClient);
    dbProvider = new com.thortech.xl.client.dataobj.tcDataBaseClient();

    ERROR Received :


    Exception in thread "main" java.lang.ExceptionInInitializerError
    at oracle.iam.platform.Platform.(Platform.java:109)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.hashAlgo(tcPasswordUtilities.java:2583)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkPasswordHistory(tcPasswordUtilities.java:876)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkProcessPasswordHistory(tcPasswordUtilities.java:842)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkProcessPasswordFull(tcPasswordUtilities.java:763)

    ReplyDelete
  3. I am trying to validate password against password policy using the code as below and I see below error. Can you advise on this

    code part :

    XLClientSecurityAssociation.setClientHandle(Platform);
    dbProvider = new com.thortech.xl.client.dataobj.tcDataBaseClient();
    tcPasswordUtilities moPwdUtil = new tcPasswordUtilities(dbProvider);
    String msg = moPwdUtil.checkProcessPasswordFull(pwrKey, password1, userLogin, "", "", Long.parseLong(orcKey));

    ERROR Received :


    Exception in thread "main" java.lang.ExceptionInInitializerError
    at oracle.iam.platform.Platform.(Platform.java:109)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.hashAlgo(tcPasswordUtilities.java:2583)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkPasswordHistory(tcPasswordUtilities.java:876)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkProcessPasswordHistory(tcPasswordUtilities.java:842)
    at com.thortech.xl.dataobj.util.tcPasswordUtilities.checkProcessPasswordFull(tcPasswordUtilities.java:763)

    ReplyDelete
  4. I have found that most of the examples with this connection is for "Select " statement, I am trying to do an update of act table, but I am getting next error: XELLERATE.DATABASE : Class/Method: tcDataBaseClient/readPartialStatement encounter some problems: {1}

    java.lang.NullPointerException: null
    Is it familiar to you?

    ReplyDelete