Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Hi,

I am a consultant at Novum GmbH in Germany and I am currently evaluating Crystal Reports.

We are looking for a reporting tool, that meets the following requirements:

  1. Provide a comfortable design tool to create report templates.
  2. Provide a Java-Runtime that can be used to create actual reports from report templates inside a Java EE application.

To evaluate the Java-Runtime I downloaded the Java Runtime – All-in-One Package from

http://downloads.businessobjects.com/akdlm/crystalreportsforeclipse/2_0/cr4e-all-in-one-win_2.0.18.z...

and the Java Runtime libraries from

http://downloads.businessobjects.com/akdlm/crystalreportsforeclipse/2_0/crjava-runtime_12.2.219.zip

So far I was able to use the crystal reports Java libraries inside an Java EE application to create a PDF-report file from

a report template that I created with the designer. The java class I wrote looks like this:

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

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

import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;

import com.businessobjects.samples.CRJavaHelper;

import java.io.ByteArrayInputStream;

public class CRRuntimeTest {

private static final Logger LOGGER = Logger.getLogger(CRRuntimeTest.class);

public void createReport() throws Exception {

ReportClientDocument clientDoc = null;

String reportTemplate = "C:/cr/reporttemplates/MyReport.rpt";

ByteArrayInputStream byteArrayInputStream = null;

try {

String jndiDataSourceName = "java:/EEDataSource";

InitialContext context = new InitialContext();

Object datasource = context.lookup(jndiDataSourceName);

String dbUserName = "user01";

String dbPassword = "sesame";

String jdbcConnectionURL = "jdbc:oracle:thin:@localhost:1521:xe";

String jdbcDriverName = "oracle.jdbc.driver.OracleDriver";

try {

// Works with an invalid JNDI name!

CRJavaHelper.changeDataSource(clientDoc, dbUserName, dbPassword, jdbcConnectionURL, jdbcDriverName, "java:/dummy");

// Does not work with a valid JNDI!

//CRJavaHelper.changeDataSource(clientDoc, dbUserName, dbPassword, jdbcConnectionURL, jdbcDriverName, jndiDataSourceName);

} catch (ReportSDKException rex) {

LOGGER.error("changeDataSource failed.", rex);

}

try {

byteArrayInputStream = (ByteArrayInputStream) clientDoc

.getPrintOutputController().export(ReportExportFormat.PDF);

} catch (ReportSDKException rex) {

LOGGER.error("Fehler beim PDF-Export.", rex);

erg.addCurrentValue();

return erg;

}

....

} finally {

....

}

}

}

I am using the CRJavaHelper class from the All-in-One Package to replace the data source in the report template.

This works fine, if I call CRJavaHelper.changeDataSource with all the typical arguments for a JDBC connection and an

invalid jndiDataSourceName ("java:/dummy").

However inside my Java EE application I do not want to bother with the detailed properties of the JDBC connection.

I’d rather work with the proper data source that is provided by my Java EE Container and which  can be accessed using JNDI.

I tried to call the CRJavaHelper.changeDataSource with a valid jndiDataSourceName ("java:/EEDataSource ") but this

produced the following ReportSDKException:

  1. com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Unerwarteter Datenbank-Connector-Fehler---- Error code:-2147467259 Error code name:failed

I need to be able to replace the data source inside a report template with a JNDI data source that is available in my JEE-Container.

Is there a more detailed documentation or an example on how to replace a data source in a report template

by passing a jndi name or a data source object inside a Java EE application?

I would appreciate iyour help.

Regards, Michael

Labels in this area