Showing results for 
Search instead for 
Did you mean: 

change report database connection

Former Member
0 Kudos


I'm trying to make a java application which changes the reports database connection.

My reports use odbc connection.

I read the examples and I succesfuly changed to or jdbc.odbc but I want

to chnage the connection to oracle or other odbc.

I wrote the code:

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

propertyBag.put("Connection String", "Server=s(aurel);User ID=s(aurel);Password=;Trusted_Connection=b(false)");

propertyBag.put("Server Type", "Oracle Server");

propertyBag.put("Database DLL","crdb_oracle.dll");





//Update old table in the report with the new table.

databaseController.setTableLocation(table, tables.getTable(i));

When I run it I got the error:

JRCAgent1 detected an exception: Database driver name is not supported: crdb_oracle.dll Database driver name is not supported: crdb_oracle.dll

This happened also when I use odbc connection with crdb_odbc.dll

I want to know if I can do that or is it impossible?

I don't need to change the connection for each table I like to change it for the entire report

like in crystal reports when use set datasource location but I don't find any support for that.


Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The Java Reporting Component (JRC) supports Java-based connectivity, including JDBC, JNDI, JavaBeans, POJO and XML.

Unfortunately, it does not support ODBC or native Oracle.

The error you're getting is JRC complaining it doesn't know how to support native Oracle connections.

Ted Ueda

Former Member
0 Kudos

In my web searching I found this:


public void setTableLocation(java.lang.String subreportName,

ITable curTable,

ITable newTable)

throws ReportSDKException

Sets the location of a table to a database that is different from the one originally specified when creating the subreport. Use this method to change the location of a database table that is active in a subreport. This is especially useful if a subreport uses a database that has a different location on your system, or if you have changed the directory or disk location of a database.

Note: This method does not physically move the database. It simply looks for the database table in a location other than the one originally specified when setting up the subreport.

This method also allows you to change the database driver DLL being used. For example, you can change from crdb_odbc.dll to crdb_oracle.dll. See the Crystal Reports Developer Runtime Help for a list of database driver DLLs.

In the last 4 lines it is said that I can do exactly what I need.Unfortunately I didn't find how anywhere.

And if this is true and work for subreports why shouldn't work for the entire report?

Or I didn't understand right what those lines mean?

Former Member
0 Kudos

The JRC does not support native Oracle or ODBC - when it encounters an ODBC connection within a report, it tries to connect to a JNDI connection with the same name.

The setTableLocation method is used not just with the JRC SDK but with the RAS SDK - the RAS server supports native Oracle and ODBC.

The JRC uses the Java Report Engine runtime, and not the Crystal reports Developer Runtime.

The setTableLocation works for both the main and subreports. It's specifically the non-support of native Oracle that's throwing the exception you see.


Ted Ueda

Former Member
0 Kudos

Thanks for your replies Ted.

I'm clarified now.

Former Member
0 Kudos

I have a problem when i am trying to open a report using the RAS-engine and to change the database connection. In the report designer i chose OracleDriver and i tried aswell a JDBC connection using the oracle driver class. at runtimer i tried to change to a jdbc-jndi connection and the oracle driver class. so anyways, the error always occure at the method setTableLocation()....

i think this is odd because i used the same code with the ReportClientDocument-class of the JRC and it just ran without any errors.

I also added the path of the "ojdbc14.jar" (jdbc-driver for oracle) to the CLASSPATH of my CRConfig.xml which ist stored in C:ProgrammeBusiness Objectscommon3.5java...because i thought it could be related with that.

first here is the error-output: eption: Fehler beim Öffnen der Verbindung.

Fehler beim Öffnen der Verbindung.

C:WINDOWSTEMP{C5CE14C8-0E3C-405B-AA2E-8CB3465FDE40}.rpt- --- Error code:-2147482892 Error code name:failed

at ption.throwReportSDKServerException(Unknown Source)

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

at n Source)

at n Source)

at wn Source)

at own Source)

at own Source)

at com.crystaldecisions.proxy.remoteagent.u.performDo(Unknown Source)

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

at troller.a(Unknown Source)

at troller.setTableLocation(Unknown Source)

at troller.a(Unknown Source)

at troller.setTableLocationEx(Unknown Source)

at test.DbChanger.setDatabaseConnection(

at test.RASexample.main(

now here are my example class and code:

public class RASexample


static final String EXPORT_FILE = "C:


public static void main(String[] args)


String REPORT_NAME = "D:

Crystal Reports



try {

//Open report. tDocument rpt = new tDocument();

ReportAppSession ra = new ReportAppSession();

ra.createService(" cation.ReportClientDocument");



rpt.setReportAppServer(ra.getReportAppServer());"rassdk://" + REPORT_NAME, 0);

DbChanger dbchange = new DbChanger();



InputStream byteArrayInputStream = rpt.getPrintOutputController().export(ReportExportFormat.PDF );

// Release report.


//Use the Java I/O libraries to write the exported content to the file system.

byte byteArray[] = new byte[byteArrayInputStream.available()];

//Create a new file that will contain the exported result.

File file = new File(EXPORT_FILE);

FileOutputStream fileOutputStream = new FileOutputStream(file);

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());

int x =, 0, byteArrayInputStream.available());

byteArrayOutputStream.write(byteArray, 0, x);


//Close streams.




System.out.println("Successfully exported report to " + EXPORT_FILE);


catch(Exception ex) {






CLASS DBchanger




public class DbChanger


public String dbUrl = "jdbc:oracle:thin:@*******:**:***";

public String driverClass = "oracle.jdbc.driver.OracleDriver";

public String dbUsername = "*****";

public String dbPassword = "*****";

public String dbUri = "";

public String dbName = "";

public void setDBInformation()


//set DataBaseName

int index = this.dbUrl.lastIndexOf(":");

if (index > 0) {

this.dbName = this.dbUrl.substring(index + 1);


//set DataBase URI

String[] split = this.dbUrl.split("@");

this.dbUri = "!" + this.driverClass + "!" + split[0] + this.dbUsername + "/" + this.dbPassword + "@" + split[1]

+ "!; DatabaseName=" + this.dbName + ";user=" + this.dbUsername + ";password=" + this.dbPassword + "!";


public void setDatabaseConnection( pplication.DatabaseController databaseController) throws Exception


//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 connectionString = "Use JDBC=b(true);Connection URL=s(" + this.dbUrl + ");" + "Database Class Name=s("

+ this.driverClass + "); User ID=s(" + this.dbUsername + ");Password=s(" + this.dbPassword

+ ");Trusted_Connection=b(false);";

final String databaseDll = "crdb_jdbc.dll";

final String tableNameQualifier = "";

//Obtain collection of tables from this database controller.

Tables tables = databaseController.getDatabase().getTables();

//Set the datasource for all main report tables.

//text was cut off if i used the char for

for (int i = 0; i tables.size(); i++)


ITable origTable = tables.getTable(i);

ITable newTable = (ITable)origTable.clone(true);

//Keep existing name and alias.



//Change properties that are different from the original datasource.

newTable.setQualifiedName(tableNameQualifier + origTable.getName());

//Change connection information properties.

IConnectionInfo connectionInfo = origTable.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("Connection String", connectionString);

propertyBag.put("Database Name", this.dbName);

propertyBag.put("Server Type", "JDBC (JNDI)");

propertyBag.put("URI", this.dbUri);

propertyBag.put("Use JDBC", "true");

propertyBag.put("Database DLL", databaseDll);


//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(origTable, newTable);




Former Member
0 Kudos

Are you using a SQL Command with parameters in your datasource?