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

Crystal Reports for Java - ReportViewerBean class


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.


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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 08, 2009 at 02:46 PM


    Which version of Crystal Reports are you using?



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Ted Ueda

      > 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:




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

      for (ITable table : t) {


      setting new conn for each table--

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

      PropertyBag pb = new PropertyBag();

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

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

      pb.putStringValue("Database", dbName);

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

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

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

      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", "");

      IConnectionInfo connInfo = new ConnectionInfo();






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




      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?



  • Posted on Apr 08, 2009 at 04:42 PM

    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.


    Ted Ueda

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 14, 2009 at 02:01 AM

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

    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.