Skip to Content
author's profile photo Former Member
Former Member

how to change datasource for subreports?

Hi everyone,

I have been using CR4E for the last couple weeks and its been working quite nice.

Today I have been trying to create a Java war file for tomcat deployment. I've been creating reports in our development database and now I want to switch their connections to production.

Here is what I did:

ConnectionInfos connInfos = new ConnectionInfos();        	
ConnectionInfo connInfo = new ConnectionInfo();  
PropertyBag pb = new PropertyBag();
pb.put(PropertyBagHelper.CONNINFO_JDBC_CONNECTION_URL, connection_string);
pb.put(PropertyBagHelper.CONNINFO_JDBC_DATABASECLASSNAME, database_class_name);
connInfo.setUserName(username);
connInfo.setPassword(password);
connInfos.add(connInfo);
        	
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(report_name, 0);
Object reportSource = reportClientDoc.getReportSource();
CrystalReportViewer crv = new CrystalReportViewer();

(rest of code removed)

That is my basic setup. I switched my database to production and everything was working smooth. Today, I added a subreport to a report, and it gave me a "database login invalid" message. I searched this board and I suspect it is because the subreport still contains the original development database connection string, while trying to use my production username and password coming in from connInfo.

Link: [https://forums.sdn.sap.com/thread.jspa?threadID=1120745&tstart=30]

In this thread Miguel shows how to loop through and switch the database connection of the subreports.

I had two questions - 1) is this the preferred way to switch subreport datasources, and if not, can it be acheived in a different manner (perhaps using CRConfig.xml) ? and 2) With Miguel's way, he ran into a problem with subreports not calling close() and thus overloading CR's connections. Has this been resolved or will it be resolved in the future?

Thank you very much!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:37 PM

    Hello -

    I just wanted to report that I have fixed the problem by following the "changing datasources" sample code on this site.

    Thanks,

    Jin

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.