Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Crystal Reports + JSP + com/crystaldecisions/reports/reportengineinterface/

843838Jun 15 2006
hi,
I am using Crystal Reports and JSPs to create and display reports from an Oracle database. When i try to access the report from the JSP, I get the following error:

com/crystaldecisions/reports/reportengineinterface/a/a/b

I did go through this forum, and one thread suggested that I add the CrystalReportEngine.jar file in my /lib directory. I have done that but it still gives me the error.
The code below is taken from a list of examples on the Businees Objects site with a few modifications made by me:


There are two files:
1. The jrc_dataset_datasource.jsp file
<%
/*
* Applies to versions: XI Release 2
* Date Created: December 2005
* Description: This sample demonstrates how to push a runtime Java Resultset to a
* report as a datasource.
* Author: CW.
*/
%>

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%//Crystal Java Reporting Component (JRC) imports.%>
<%@page import="com.crystaldecisions.reports.sdk.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>

<%//Java imports. %>
<%@page import="java.sql.*" %>

<%
//Report can be opened from the relative location specified in the CRConfig.xml, or the report location
//tag can be removed to open the reports as Java resources or using an absolute path (absolute path not recommended
//for Web applications).
final String REPORT_NAME ="report.rpt";
%>

<%
try {

//Open report.
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(REPORT_NAME, 0);

//Create SQL query.
String query = "SELECT <attributes> FROM <table name>";

//Query database and obtain the Resultset that will be pushed into the report.
ResultSet resultSet = getResultSetFromQuery(query, ResultSet.TYPE_SCROLL_INSENSITIVE);

//Look up existing table in the report to set the datasource for and obtain its alias. This table must
//have the same schema as the Resultset that is being pushed in at runtime. The table could be created
//from a Field Definition File, a Command Object, or regular database table. As long the Resultset
//schema has the same field names and types, then the Resultset can be used as the datasource for the table.
String tableAlias = reportClientDoc.getDatabaseController().getDatabase().getTables().getTable(0).getAlias();

//Push the Java ResultSet into the report. This will then be the datasource of the report.
reportClientDoc.getDatabaseController().setDataSource(resultSet, tableAlias , "resultsetTable");

//Store the report source in session, will be used by the CrystalReportViewer.
session.setAttribute("reportSource", reportClientDoc.getReportSource());

//Launch CrystalReportViewer page that contains the report viewer.
response.sendRedirect("CrystalReportViewer.jsp");

}
catch(ReportSDKException ex) {
out.println(ex);
}
catch(Exception ex) {
out.println(ex);
}
%>

<%!
/**
* Simple utility function for obtaining result sets that will be pushed into the report.
* This is just standard querying of a Java result set and does NOT involve any
* Crystal JRC SDK functions.
*/
private static ResultSet getResultSetFromQuery(String query, int scrollType) throws SQLException, ClassNotFoundException {

//Load JDBC driver for the database that will be queried.


//Construct JDBC connection.
Class.forName("oracle.jdbc.driver.OracleDriver");

java.sql.Connection connection = DriverManager.getConnection(CONNECTION_URL, DBUSERNAME, DBPASSWORD);

Statement statement = con.createStatement(scrollType, ResultSet.CONCUR_READ_ONLY);

//Execute query and return result sets.
return statement.executeQuery(query);

}


%>


2. The CrystalViewer.jsp file is

<%
/*
* Applies to: XI Release 2.
* Date Created: December 2005.
* Description: This sample demonstrates to how to launch a report in the Crystal Report DHTML viewer (CrystalReportViewer).
* NOTE: The CrystalReportViewer is kept on this special viewer page as the viewer also will 'post-back' during
* a viewer event such as page navigation, drill down, or launching other toolbar commands. The viewer
* then renders a new 'view' of the report source object previously created before calling this page and stored in session.
* Author: CW
*/
%>

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%//Crystal Report Viewer imports.%>
<%@page import="com.crystaldecisions.report.web.viewer.*"%>
<%@page import="com.crystaldecisions.reports.sdk.*" %>

<%

//Refer to the Viewers SDK in the Java Developer Documentation for more information on using the CrystalReportViewer
//API.
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setOwnPage(true);
viewer.setOwnForm(true);
viewer.setPrintMode(CrPrintMode.ACTIVEX);

//Get the report source object that this viewer will be displaying.
Object reportSource = session.getAttribute("reportSource");
viewer.setReportSource(reportSource);

//Render the report.
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

%>

I would be really grateful for any help on this .
Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2006
Added on Jun 15 2006
0 comments
531 views