cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports for Java - ReportViewerBean class

Former Member
0 Kudos

Hi,

I have a Java desktop application and I want to integrate a Crystal Reports viewer in it.

The application is made with SWT and I have integrated the Swing viewer provided by the class com.crystaldecisions.ReportViewer.ReportViewerBean. The strange thing is that only reports with saved data inside are working. The reports made without saving data are not working with this ReportViewerBean.

I need to view reports with no saved data inside them, so my question is:

anyone knows if this ReportViewerBean class works with the reports with no data saved inside them?

I also want to change the connection details as well as the database name, username, password and the report parameter values programmatically. Those are also not working with the ReportViewerBean class.

Please help me.

Thanx

PS: i can provide the source code if someone needs it.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

MS SQL Server requires a Server, database, USer, Password to be named in the connection properties

ted_ueda
Active Contributor
0 Kudos

Ok, so when you say "not working", the first question that comes to mind is "How is it not working"?

It's real hard to help you if you withhold vital info.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi,

Which version of Crystal Reports are you using?

Thanks,

Tej

Former Member
0 Kudos

> Hi,

> Which version of Crystal Reports are you using?

>

> Thanks,

> Tej

Hello there,

The Crystal Reports version is 2008.

Details: I've downloaded the Crystal Reports for Eclipse 2.0 and I made a report with that. The report was saved with all the data embeded in it so I made the report with Crystal Reports without saving any data in it.

-


> Ok, so when you say "not working", the first question that comes to mind is "How is it not working"?

>

> It's real hard to help you if you withhold vital info.

>

> Sincerely,

>

> Ted Ueda

Sorry for not missing that out, I'm not trying to withhold any info. The problem is that when I try to view a report with no data embeded, I got an error ("Logon Error: Login failed for user 'xxx'.") and a window asking for database connection details is popping out. Here is the screenshot:

http://img8.imageshack.us/img8/8051/crerror.jpg

After I'm entering the user and password I got a second window with an error:

http://img27.imageshack.us/img27/9795/crerror2.jpg

The stacktrace of the error is:

-


START STACK -


ERROR 09:43:32,110 (?:?) - detected an exception: com/crystaldecisions/reports/queryengine/querybuilder/ExtendableOptions

at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.if(Unknown Source)

at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(Unknown Source)

at com.crystaldecisions.reports.queryengine.JDBConnectionWrapper.Open(Unknown Source)

at com.crystaldecisions.reports.queryengine.Connection.bv(Unknown Source)

at com.crystaldecisions.reports.queryengine.Connection.bv(Unknown Source)

at com.crystaldecisions.reports.queryengine.Connection.va(Unknown Source)

at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.a(Unknown Source)

at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.for(Unknown Source)

at com.crystaldecisions.reports.reportdefinition.ReportHelper.a(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.long(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(Unknown Source)

at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.byte(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(Unknown Source)

at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(Unknown Source)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)

at com.businessobjects.sdk.erom.jrc.a.a(Unknown Source)

at com.businessobjects.sdk.erom.jrc.a.execute(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(Unknown Source)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ds.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.ReportSource.getPage(Unknown Source)

at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.getPage(Unknown Source)

at com.businessobjects.crystalreports.viewer.core.rs.RSRecordSource.openInputStream(Unknown Source)

at com.businessobjects.crystalreports.viewer.core.TSLVReader.a(Unknown Source)

at com.businessobjects.crystalreports.viewer.core.TSLVReader.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

com/crystaldecisions/reports/queryengine/querybuilder/ExtendableOptions

-


END STACK -


So after all that the report is not loaded and the viewer remains empty.

I don't know why I'm being asked for the database user & password since the original details are correct.

Any suggestions?

I talked with some people from the company which sells CR in my country and they told me that the ReportViewerBean is only able to show reports saved with data embeded.

Thanks,

Sergiu

ted_ueda
Active Contributor
0 Kudos

You can use ReportViewerBean to refresh reports - report refresh is handled by the backend engine, and not the viewer component.

Note that it's asking for database logon since Crystal, for security purposes, do not save the db password with the report. You either have to enter it via the viewer or programmatically.

First test - open the report in the CR4E embedded designer in Eclipse on the same machine as where you get the error in your app, and refresh. Does it connect?

Second test - open the report in CR 2008 Designer on the same machine, and refresh. Does it connect?

The above two ensures db connection via both the CR engine and the CR Java engine, before proceeding with your own app.

Sincerely,

Ted Ueda

Former Member
0 Kudos

The tests succeeded, the report connect's to the database and refresh the data. About the database logon I had set it's properties programmatically:

com.businessobjects.samples.CRHelper.changeDataSource(reportClientDocument, "", "", "username", "password",

"jdbc:sqlserver://192.168.0.36:55555", "com.microsoft.sqlserver.jdbc.SQLServerDriver", null);

but it seems that this method has no effect because even if I change the username I get the logon error for the same username that was set in the report.

Maybe it is some other method to change the data source from source code but I did not found it.

Thanks,

Sergiu

ted_ueda
Active Contributor
0 Kudos

Then don't use the sample helper code, but try passing in the logon via:

reportClientDocument.getDatabaseController().logon(...);

and for each subreport, if you have them, as well.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hello there,

I used the logon() function like that:

The good thing is that now I don't get the dialog asking me to enter the db login details.

The bad thing is that I still got the error message from http://img27.imageshack.us/img27/9795/crerror2.jpg and the same error:

ERROR 09:43:32,110 (?:?) - detected an exception: com/crystaldecisions/reports/queryengine/querybuilder/ExtendableOptions

at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.if(Unknown Source)

at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(Unknown Source)

at com.crystaldecisions.reports.queryengine.JDBConnectionWrapper.Open(Unknown Source)

...

Maybe I'm not doing something right, so is here what I did - the Java source:

-


START SOURCE CODE -


...

import com.crystaldecisions.ReportViewer.ReportViewerBean;

import com.crystaldecisions.sdk.occa.report.application.OpenReportOptions;

import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;

import com.crystaldecisions.sdk.occa.report.data.ConnectionInfo;

import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;

import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;

import com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper;

import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;

...

private ReportViewerBean reportViewer;

private ReportClientDocument reportClientDocument;

...

reportViewer = new ReportViewerBean();

reportViewer.init();

frame.add(reportViewer, BorderLayout.CENTER);

// Start the viewer

reportViewer.start();

...

reportClientDocument = new ReportClientDocument();

reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);

reportClientDocument.open(filePath, OpenReportOptions._openAsReadOnly);

//logon

PropertyBag propertyBag = new PropertyBag();

IConnectionInfo connectionInfo = new ConnectionInfo();

propertyBag.putStringValue("SSO Enabled", "false");

propertyBag.putStringValue(PropertyBagHelper.CONNINFO_JDBC_CONNECTION_URL,

"jdbc:sqlserver://192.168.0.36:55555");

propertyBag.putStringValue(PropertyBagHelper.CONNINFO_JDBC_DATABASECLASSNAME,

"com.microsoft.sqlserver.jdbc.SQLServerDriver");

propertyBag.putStringValue(PropertyBagHelper.CONNINFO_DATABASE_NAME, "work");

propertyBag.putStringValue(PropertyBagHelper.CONNINFO_CRQE_DATABASENAME, "work");

connectionInfo.setAttributes(propertyBag);

reportClientDocument.getDatabaseController().logon(connectionInfo, "sa", "a");

reportViewer.setReportSource(reportClientDocument.getReportSource());

-


END SOURCE CODE -


The login to the DB server is ok now, I looked with the profiler and indeed the login is made succesfully.

What I'm doing wrong? I'm not usgin the right packages? Is my code wrong ?

Note: I saw that the class "ExtendableOptions" is in the 2 places:

- one in package "com.crystaldecisions.reports.queryengine.querybuilder"

- another in package "com.crystaldecisions12.reports.queryengine.querybuilder"

I tried changing the imports from com.crystaldecisions.* to com.crystaldecisions12.* but I have some other strange errors.

Thank you,

Sergiu

Former Member
0 Kudos

hmm..... in some way the problem is solved:

I changed the class from com.crystaldecisions.sdk.occa.report.application.ReportClientDocument to com.crystaldecisions.reports.sdk.ReportClientDocument.

Strange, now it works. But following you article (CR4E Version 2 - Migrating From Java Reporting Component SDK to Crystal Reports Java SDK), I can change the JRC package com.crystaldecisions.reports.sdk to the CRJ package com.crystaldecisions.sdk.occa.report.application.

With com.crystaldecisions.sdk.occa.report.application it doesn't work.

ted_ueda
Active Contributor
0 Kudos

Note that the JRC classes are wrappers around CRJ classes - it was like that before CR4E 2.0, just that the CRJ classes (actually RAS classes) were never part of the public API before.

What's strange is that I've not seen your issue before, and your exception is raised back-end, both JRC and CRJ goes to the same backend.

Sincerely,

Ted Ueda

Former Member
0 Kudos

> Posted: Apr 9, 2009 6:37 PM in response to: juliuspms Reply

>

> Then don't use the sample helper code, but try passing in the logon via:

>

> reportClientDocument.getDatabaseController().logon(...);

>

> and for each subreport, if you have them, as well.

>

> Sincerely,

>

> Ted Ueda

Hello again,

It seems that I still have problems changing the server and database for the reports, I can't change them programmatically at runtime.

If I use the reportClientDocument.getDatabaseController().logon(String user, String password) is ok, the user and password are ok. But it's only the user and password.

I'm trying to set the connection properties with reportClientDocument.getDatabaseController().getDatabase().setConnections(connections);

where I'm setting different server and database names but the report is shown with the data from the server/database chosen when the report was created.

I've tried to change connection properties for each table from the report but still no effect.

Here is what I've done:

-


START SOURCE CODE

-


Tables t = reportClientDocument.getDatabaseController().getDatabase().getTables();

for (ITable table : t) {

//--


setting new conn for each table--


String connString = "jdbc:sqlserver://192.168.0.36:55555;databaseName=" + dbName;

PropertyBag pb = new PropertyBag();

pb.putStringValue("JDBC Connection String", connString);

pb.putStringValue("PreQEServerName", "jdbc:sqlserver://192.168.0.36:55555");

pb.putStringValue("Database", dbName);

pb.putStringValue("Server Name", "jdbc:sqlserver://192.168.0.36:55555");

pb.putStringValue("Connection URL", "jdbc:sqlserver://192.168.0.36:55555");

pb.putStringValue("Server", "192.168.0.36");

pb.putStringValue("Server Type", "JDBC (JNDI)");

pb.putStringValue("Database DLL", "crdb_jdbc.dll");

pb.putStringValue("Use JDBC", "true");

pb.putStringValue("Trusted_Connection", "false");

pb.putStringValue("Database Class Name", "com.microsoft.sqlserver.jdbc.SQLServerDriver");

IConnectionInfo connInfo = new ConnectionInfo();

connInfo.setAttributes(pb);

connInfo.setUserName(userName);

connInfo.setPassword(password);

table.setConnectionInfo(connInfo);

}

reportClientDocument.getDatabaseController().logon(p.getUser(), p.getPassword());

-


END SOURCE CODE

-


I have 2 databases: "test" (here I test the reports, this is the database which name is saved within the report) and "work" (production database, passed on the connection info - see above).

Assuming I have a simple report with a simple SQL, when I view the report the following SQL is executed (seen with the profiler):

SELECT field1, field2 FROM "test"."dbo"."table_name" "table_name"

The SQL is not changed with the new database location send in connection info.

I also tried to change the table qualified name like that:

String qName = table.getQualifiedName(); //table q. name is like "db".dbo."table_name"

int pos = qName.lastIndexOf('.');

table.setQualifiedName(qName.substring(pos + 1));

but no success.

Is there any way to change the server and database at runtime?

Thanks,

Serj