cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO PASS DATA BASE INFO TO THE REPORT WHEN IT'S SUB REPORT IS CONNECTED TO DIFFERENT DATA SOURCE

SJohnson
Employee
Employee
0 Kudos

<p><COPIED FROM BETA FORUMS> </p><p>Hi all,<br />I have recently entered into crystal reports integration with JSP. I have designed a report by selecting ODBC(RDO) and what ever the data source I have in my system. <br />Now I need to pass data base info dynamically to that report from JSP. Here one important thing is I desinged the report and it&#39;s sub reports by connecting to only one data source. In this scenario I am able to pass all below conncetion information dynamically and able to view report.<br /><br />Connection URL: jdbc:oracle:thin:@SERVERNAME:1521:SID<br />Class name : oracle.jdbc.driver.OracleDriver<br />Username; user<br />Password: pwd<br /><br />Code for passing connection info to main report<br />--


<br /> Tables mainTableCollection = (Tables)rptDoc.getDatabaseController().getDatabase().getTables();<br /> ITable originalTableMain = null;<br /> ITable newTableMain = null;<br /> for(int j = 0;j < mainTableCollection.size();j+)<br /> {<br /> originalTableMain = mainTableCollection.getTable(j);<br /> PropertyBag pBag = originalTableMain.getConnectionInfo().getAttributes();<br /> System.out.println("QE_ServerDescription (dsn) is : "pBag.get("QE_ServerDescription"));<br /> newTableMain = mainTableCollection.getTable(j);<br /> ConnectionInfo ci = (ConnectionInfo)newTableMain.getConnectionInfo();<br /><br /> PropertyBag logonProps = new PropertyBag();<br /> logonProps.put("Database Class Name","oracle.jdbc.driver.OracleDriver");<br /> logonProps.put("Connection URL","jdbc:oracle:thin:@SERVERNAME:1521:SID");<br /> PropertyBag pb = new PropertyBag();<br /> pb.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES ,logonProps);<br /> pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL ,"crdb_jdbc.dll");<br /> ci.setAttributes(pb); <br /><br /> ci.setUserName("myuser");<br /> ci.setPassword("mypwd");<br /> newTableMain.setConnectionInfo(ci);<br /> rptDoc.getDatabaseController().setTableLocation(originalTableMain, newTableMain);<br /> System.out.println(" User Name : "originalTableMain.getConnectionInfo().getUserName());<br /> System.out.println(" Password : "originalTableMain.getConnectionInfo().getPassword());<br /> }<br /> <br />For sub reports:<br />
<br />IStrings subreportNames = rptDoc.getSubreportController().getSubreportNames();<br /> if(subreportNames.size() != 0)<br /> {<br /> for (int i = 0; i < subreportNames.size(); i++ )<br /> {<br /> <br /> ISubreportClientDocument subreportClientDoc = rptDoc.getSubreportController().getSubreport(subreportNames.getString(i));<br /> Tables oTablesCollection = (Tables)subreportClientDoc.getDatabaseController().getDatabase().getTables();<br /> ITable originalTable = null;<br /> ITable newTable = null;<br /> for(int j = 0;j < oTablesCollection.size();j+)<br /> {<br /> originalTable = oTablesCollection.getTable(j);<br /> PropertyBag pBag = originalTable.getConnectionInfo().getAttributes();<br /> System.out.println("Property Bag - charging broker condtion : "pBag);<br /> System.out.println("QE_ServerDescription (dsn) - sub reports : "pBag.get("QE_ServerDescription"));<br /> newTable = oTablesCollection.getTable(j);<br /> ConnectionInfo ci = (ConnectionInfo)newTable.getConnectionInfo();<br /> <br /> PropertyBag logonProps = new PropertyBag();<br /> logonProps.put("Database Class Name","oracle.jdbc.driver.OracleDriver");<br /> logonProps.put("Connection URL","jdbc:oracle:thin:@SERVERNAME:1521:SID");<br /> PropertyBag pb = new PropertyBag();<br /> pb.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES ,logonProps);<br /> pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL ,"crdb_jdbc.dll");<br /> ci.setAttributes(pb); <br /><br /> ci.setUserName("myuser");<br /> ci.setPassword("mypwd");<br /> newTable.setConnectionInfo(ci);<br /> subreportClientDoc.getDatabaseController().setTableLocation(originalTable, newTable);<br /> System.out.println("User Name : "originalTable.getConnectionInfo().getUserName());<br /> System.out.println("Pass word : "+originalTable.getConnectionInfo().getPassword());<br /> <br /> }<br /> }<br /> }<br /> <br /><br /><br />Up to this no problems for me. Now I have another reports which was also designed by ODBC(RDO) and main report and all sub reports are pointing to same data source except one sub report. This sub report is pointing to other data source.<br />As above mentioned code I tired to send connection information. But I am getting follwing error.<br /><br />com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: The Report Application Server failed.
-- Error code:-2147482651 Error code name:failed<br /><br />I don&#39;t know why it is coming........!!!!!!!!<br />if any body has any solution for this problem please provide me. It's very urgent for me.<br /><br />So simply, the problem is "HOW TO PASS DATA BASE INFO TO THE REPORT WHEN SUB REPORT IS CONNECTED TO DIFFERENT DATA SOURCE THAN MAIN REPORT"<br /><br />thanks in advance<br /><br />Rgds,<br />surya,<br />eMail Id : yerram.surya-sekhar@hp.com<br />suryasekhar_yerram@yahoo.co.in</p>

Accepted Solutions (0)

Answers (1)

Answers (1)

SJohnson
Employee
Employee
0 Kudos

<p>Hi Surya,</p><p> Crystal Reports for Eclipse includes a very convenient wizard which will auto-generate the required stub code you will need to change database location at runtime. To access the wizard you can right-click on a report and choose:</p><p> <strong>Crystal Reports ->Create Viewer JSP </strong><br /></p><p><img src="http://static.flickr.com/69/215495260_0221e54dd6.jpg?v=0" /> </p><p>This will launch the following wizard:</p><p><img src="http://static.flickr.com/81/215495261_9793a6cc10.jpg?v=0" /> </p><p>If you look you will see that there is an option to change the data source at runtime. Select this and the required stub code should be added to your JSP page</p><p>This wizard actually analyzes the selected report and creates custom stub code based on the number of database connections, number of subreports, etc.</p><p>It should really simplify what you are trying do.</p><p>The resulting JSP actually makes call to a helper class <strong>JRCHelperSample</strong> which is where most of our API calls and logic are made. This class will be found in the src folder of a web project under the <strong>com.businessobjects.samples</strong> folder. Users can look to this class for samples on how to do things and modify to suit their needs.</p><p>Hopefully this helps.</p><p>Regards,<br />Sean<br /> </p>

Former Member
0 Kudos

<p>i have not got the above feature for crystal reports,due to some limitations,i am using reports and subreports with different datasources(two .ttx) files are being used,the Subreports table alias is correctly identified by my program but in the viewar jsp exceptions come.</p><font size="2" color="#0000ff"><p>com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Unexpected Query Engine error---- Error code:-2147467259 Error code name:failed</p><p>at com.crystaldecisions.sdk.occa.report.lib.ReportSDKException.throwReportSDKException(Unknown Source)</p><p>at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.getPage(Unknown Source)</p><p>at com.crystaldecisions.report.web.event.aa.a(Unknown Source)</p><p>at com.crystaldecisions.report.web.event.aa.a(Unknown Source)</p><p>at com.crystaldecisions.report.web.event.bx.a(Unknown Source)</p><p>at com.crystaldecisions.report.web.event.b1.broadcast(Unknown Source)</p><p>at com.crystaldecisions.report.web.event.as.a(Unknown Source)</p><p>at com.crystaldecisions.report.web.WorkflowController.if(Unknown Source)</p><p>at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source)</p><p>at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)</p><p>at com.crystaldecisions.report.web.ServerControl.processHttpRequest(Unknown Source)</p><p>at com.crystaldecisions.report.web.viewer.taglib.ServerControlTag.doEndTag(Unknown Source)</p><p>at com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(Unknown Source)</p><p>at org.apache.jsp._Display._jspService(_Display.java:152)</p><p>at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)</p><p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)</p><p>at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)</p><p>at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:683)</p><p>at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:781)</p><p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)</p><p>at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)</p><p>at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)</p><p>at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)</p><p>at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)</p><p>at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)</p><p>at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)</p><p>at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1019)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:592)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)</p><p>at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)</p><p>at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)</p><p>at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)</p><p>at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)</p><p>at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)</p><p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)</p><p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)</p><p>at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)</p><p>at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)</p><p>at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)</p><p>at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)</p><p>at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)</p><p>at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)</p><p>at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1019)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:592)</p><p>at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:204)</p><p>at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)</p><p>at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:286)</p><p>at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)</p><p>at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)</p><p>at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)</p><p>at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)</p><p>at

com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:615)</p><p>at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:449)</p><p>at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)</p></font>

SJohnson
Employee
Employee
0 Kudos

<p>Hello,</p><p> What does your viewer.jsp code look like? If you paste the code into your reply I can take a quick look and see if I notice anything out of the ordinary. </p><p>Regards,<br />Sean Johnson (CR4E Product Manager) <br /><br /> <strong><a href="http://www.eclipseplugincentral.com/Web_Links-index-req-ratelink-lid-639.html">Rate this plugin @ Eclipse Plugin Central</a></strong> </p>