Skip to Content
avatar image
Former Member

How to update crystal report recurrance db logon information using java sdk

Hello Everyone, We recently had a major change in process that db teams would be changing account passwords once in every year. We mostly have crystal reports running. On search, "Schedule Manager" really saved us in updating logon details in bulk for crystal.

Challenge: Now, the report would have the correct logon details, but the recurrances would still be referring to old creds and they would fail. We have tried the below code and were able to update the recurrences db userid and pwd provided the format type of recurrence should be set to ONLY CRYSTAL. For any other format type like excel or pdf, my code fails.

Code:

IInfoStore infoStore =

(IInfoStore) enterpriseSession.getService("InfoStore");

String query = "select * from CI_INFOOBJECTS "

+ "where SI_PARENTID=421724 AND SI_RECURRING=1 AND SI_SCHEDULE_STATUS=9";

IInfoObjects infoObjects = (IInfoObjects) infoStore.query(query);

InfoObject = (IInfoObject) infoObjects.get(0);

//cast the InfoObject as a Report Object

IReport oReport = (IReport)InfoObject;

IReportLogon rptLogon = (IReportLogon) oReport.getReportLogons().get(0);

String usrname= rptLogon.getUserName();

System.out.println(usrname);

rptLogon.setUserName("bo_rept");

rptLogon.setPassword("rept4bo$");

infoStore.commit(infoObjects);

System.out.println("Report username" + "Updated Successfully!!!");

This code errors out when recurrence type is Excel. Error:

Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to com.crystaldecisions.sdk.plugin.desktop.report.IReport

at CrystalDBUpdatev1.main(CrystalDBUpdatev1.java:43)

Please help here!! Very soon my environment would see lots of scheduled failures. Environment: 4.2 SP3 Servers: Windows 2012 Tomcat 8.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • May 31, 2017 at 04:29 PM

    I just answered a surprisingly similar question on BOB. A static type (Pdf, Excel) can't be cast to IReport. You need to get the IReportProcessingInfo object from IContent.

    Untested, but the following should get you started.

    for(Object o : infoObjects)
    {
    	IReportProcessingInfo proc;
    	
    	if(o instanceof IReport)
    		proc =  ((IReportProcessingInfo)o);
    	else
    		proc = (IReportProcessingInfo) ((IContent)o).getPluginProcessingInterface(IReport.KIND);
    
    
    	IReportLogon rptLogon = (IReportLogon) proc.getReportLogons().get(0);
    	String usrname= rptLogon.getUserName();
    	System.out.println(usrname);
    	rptLogon.setUserName("bo_rept");
    	rptLogon.setPassword("rept4bo$");
    }
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 30, 2017 at 11:17 PM

    Hi Bharath, I tried but no luck. Error is:

    Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to com.crystaldecisions.sdk.plugin.desktop.report.IReportBase

    Any other pointers? I saw your blogs on RESTAPI. Do you think its possible with REST API ?

    Add comment
    10|10000 characters needed characters exceeded

  • May 30, 2017 at 12:04 AM

    Try by replacing with this line

    IReportBase oReport = (IReportBase)InfoObject;

    in the place of

    IReport oReport = (IReport)InfoObject;

    - Bharath

    Add comment
    10|10000 characters needed characters exceeded

  • May 31, 2017 at 01:48 AM

    Not possible with REST SDK.

    No APIs available for this workflow.

    Add comment
    10|10000 characters needed characters exceeded