Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

can't get to work with runtime_12.2.211

The sample program throws an exception when run with <br/>

when it gets to the line that does a setTableLocation.<br/>


The exception is java.lang.UnsupportedOperationException.<br/>



My question is:<br/>

how do I get a Java program to run a Crystal Report from version 2008,<br/>

specifically, how to set the database connection information?<br/>



The original report was created with Crystal Reports 2008.<br/>

It was created using ODBC to connect to the database.<br/>

It is a very simple report for testing, no sub reports, one table.<br/>

The program required changes before I could get it to compile.<br/>

Most of the changes are to use a diferent database/user/password/jdbc driver.<br/>

I'm trying to run a report directly from Java, not servlet/jsp/web server involved.<br/>




First I altered the so that it would compile an run.<br/>

It did run using the jar files from<br/>

Except it got this message:<br/>

Register for FREE at to remove this message<br/>

by searching around I relalized that I was not using the most recent .jar files.<br/>

This is what the program output when it ran:<br/>

Crystal Report Viewer<br/>

java.vendor = Sun Microsystems Inc.<br/>

java.version = 1.6.0_22<br/> = Windows 7<br/>

os.version = 6.1<br/>

os.arch = x86<br/>


so I moved to a new set of jar files from<br/>

This gave me this output:<br/>

0 [AWT-EventQueue-0] FATAL com.businessobjects.reports.sdk.JRCCommunicationAdapter - Request failed and JRC Command failed to be undone<br/>

2 [AWT-EventQueue-0] ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter - detected an exception: java.lang.UnsupportedOperationException<br/>

<br/> java.lang.UnsupportedOperationException---- Error code:-2147467259 Error code name:failed<br/>


at statement:<br/>

databaseController.setTableLocation(table, tables.getTable(i));<br/>


as well as a full stack trace (included below).<br/>

the program would output this if I commented out the offending line:<br/>

Crystal Reports Viewer<br/>

java.vendor = Sun Microsystems Inc.<br/>

java.version = 1.6.0_22<br/> = Windows 7<br/>

os.version = 6.1<br/>

os.arch = x86<br/>

but ofcourse the program would not connect to the database with that line commented out.<br/>


here is the stack trace (trimmed because I exceeded the character limit):<br/>


$ javac<br/>

$ java JRCChangeDatabaseConnection<br/>

0 [AWT-EventQueue-0] FATAL com.businessobjects.reports.sdk.JRCCommunicationAdapter - Request failed and JRC Command fai

led to be undone

2 [AWT-EventQueue-0] ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter - detected an exception: java.lang.


at sun.jdbc.odbc.JdbcOdbcDatabaseMetaData.getUDTs(Unknown Source)

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

at com.crystaldecisions.reports.queryengine.JDBConnectionWrapper.GetTables(SourceFile:112)



at com.crystaldecisions.reports.queryengine.Table.a(SourceFile:581)

at com.crystaldecisions.reports.queryengine.Table.u7(SourceFile:2405)


at com.crystaldecisions.reports.common.CommandManager.a(SourceFile:71)

at com.crystaldecisions.reports.common.Document.a(SourceFile:203)

at com.businessobjects.reports.sdk.requesthandler.f.a(SourceFile:175)

at com.businessobjects.reports.sdk.requesthandler.DatabaseRequestHandler.byte(SourceFile:1079)


at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:661)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:167)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(SourceFile:529)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter$

at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(SourceFile:102)

at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(SourceFile:525)


at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(SourceFile:352)

at com.businessobjects.sdk.erom.jrc.a.a(SourceFile:54)

at com.businessobjects.sdk.erom.jrc.a.execute(SourceFile:67)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(SourceFile:716)

at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(SourceFile:125)

at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:537)






at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.performDo(SourceFile:151)

at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.a(SourceFile:106)





at com.crystaldecisions.reports.sdk.DatabaseController.setTableLocation(SourceFile:51)

at JRCChangeDatabaseConnection.switch_tables(

at JRCChangeDatabaseConnection.launchApplication(

at JRCChangeDatabaseConnection$

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at Source)



here is the full program:<br/>

//Crystal Java Reporting Component (JRC) imports.
import com.crystaldecisions.ReportViewer.ReportViewerBean;
import com.crystaldecisions.reports.sdk.*;

//Java Imports.
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Insets;

import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;

public class JRCChangeDatabaseConnection extends JFrame {

	private static final String REPORT_NAME = "room_test_nw_src.rpt";
	public static void launchApplication() {
		try {
			//Open report.
			ReportClientDocument reportClientDoc = new ReportClientDocument();, 0);
			//The DatabaseController will be used to modify the connection properties of the database before 
			//viewing the report.  This method iterates through each table in the report and changes the 
			//connection info properties.  
			//Switch all tables on the main report.  See utility method below.
			//Perform the same operation against all tables in the subreport as well.
			IStrings subreportNames = reportClientDoc.getSubreportController().getSubreportNames();
			//Set the datasource for all the subreports.
			for (int i = 0; i < subreportNames.size(); i++ ) {
				ISubreportClientDocument subreportClientDoc = reportClientDoc.getSubreportController().getSubreport(subreportNames.getString(i));
				//Switch tables for each subreport in the report using the same connection information.  See utility
				//method below.
			//Launch JFrame that contains the report viewer.
			//new ReportViewerFrame(reportClientDoc);		
		    ReportViewerBean reportViewerBean = new ReportViewerBean();
		    JRCChangeDatabaseConnection frame = new JRCChangeDatabaseConnection();
		    frame.getContentPane().add(reportViewerBean, BorderLayout.CENTER);
		    Insets insets = frame.getInsets();
		    frame.setSize(insets.left + 700 + insets.right, + 500 + insets.bottom);
		catch(ReportSDKException ex) {	
		catch(Exception ex) {
	 * Sample utility method for switching the database connection properties of all tables accessible from a databaseController 
	 * (i.e., could be a main report database controller, or a subreport's database controller) from one database to another. 
	private static void switch_tables(DatabaseController databaseController) throws ReportSDKException {

		//Declare the new connection properties that report's datasource will be switched to.
		//NOTE: These are specific to using JDBC against a particular MS SQL Server database.  Be sure to use the 
		//DisplayConnectionInfo sample to determine what your own connection properties need to be set to.
		final String TABLE_NAME_QUALIFIER = "nw_src.dbo.";
		final String DBUSERNAME = "sa";
		final String DBPASSWORD = "password";
		final String SERVERNAME = ""; 
		final String CONNECTION_STRING = "Use JDBC=b(true);Connection URL=s(jdbc:microsoft:sqlserver://;" + 
										 "Database Class Name=s(;Server=s(;" + 
										 "User ID=s(vantech);Password=;Database=s(Xtreme1);Trusted_Connection=b(false);" + 
										 "JDBC Connection String=s(!!jdbc:microsoft:sqlserver://;" + 
		final String DATABASE_NAME = "nw_src";
		final String URI = "!sun.jdbc.odbc.JdbcOdbcDriver!jdbc:odbc:nw_src!";
		final String DATABASE_DLL = "crdb_jdbc.dll";
		//Obtain collection of tables from this database controller.
		Tables tables = databaseController.getDatabase().getTables();

		//Set the datasource for all main report tables.
		for (int i = 0; i < tables.size(); i++) {

			ITable table = tables.getTable(i);

			//Keep existing name and alias.
			//Change properties that are different from the original datasource.
			table.setQualifiedName(TABLE_NAME_QUALIFIER + table.getName());
			//Change connection information properties.
			IConnectionInfo connectionInfo = table.getConnectionInfo();
			//Set new table connection property attributes.
			PropertyBag propertyBag = new PropertyBag();
			//Overwrite any existing properties with updated values.
			propertyBag.put("Trusted_Connection", "false");
			propertyBag.put("Server Name", SERVERNAME); //Optional property.
			propertyBag.put("Connection String", CONNECTION_STRING);
			propertyBag.put("Database Name", DATABASE_NAME);
			propertyBag.put("Server Type", "JDBC (JNDI)");
			propertyBag.put("URI", URI);
			propertyBag.put("Use JDBC", "true");
			propertyBag.put("Database DLL", DATABASE_DLL);
			//Set database username and password.
			//NOTE: Even if these the username and password properties don't change when switching databases, the 
			//database password is *not* saved in the report and must be set at runtime if the database is secured.  
			//Update old table in the report with the new table.
			databaseController.setTableLocation(table, tables.getTable(i));
	public static void main(String [] args) {

		//Event-dispatching thread to run Swing GUI.  This is good practice for Swing applications
		//to help ensure that events are dispatched in a predicatable order. 
		//For more information on using this method, refer to the SUN site below for more details:
		SwingUtilities.invokeLater(new Runnable() { 
			public void run() {
				//Hand-off to worker function to start application.

Not what you were looking for? View more on this topic or Ask a question