|
Hi, I'm using CryatalReportXI MySql 5.0 MySql-Jdbc Connector 5.0.4 and Net Beans IDE. I'm connecting report from JSP.In CRConfig.xml, Iadded MySql-Jdbc Connector.jar, Here's the code
<jsp:useBean id="dbConnection" class="com.eaglelot.gamedesk.DBConnection" scope="request" /> <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import="com.crystaldecisions.reports.sdk.*" %> <%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %> <%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %> <%@page import="com.crystaldecisions.sdk.occa.report.data.*" %> <%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %> <%@page import="com.crystaldecisions.report.web.viewer.*"%> <%@page import="java.util.*"%>
<% HashMap userModule=new HashMap(); if(session.getValue("userName")==null) { response.sendRedirect("../userlogin.jsp"); } dbConnection.makeDatabaseConnection(); String userName=dbConnection.getUserName(); String password=dbConnection.getPassword(); String ViewType=""; String reportName=""; reportName="rptunclaimedticket.rpt";
try { Object objReportSource = null; ReportClientDocument objReportClientDocument = new ReportClientDocument(); objReportClientDocument.open(reportName, 0); objReportSource = objReportClientDocument.getReportSource(); ConnectionInfos objConnectionInfos = new ConnectionInfos(); ConnectionInfo objConnectionInfo = new ConnectionInfo(); objConnectionInfo.setUserName(userName); objConnectionInfo.setPassword(password); objConnectionInfos.add(objConnectionInfo); Fields objFields = new Fields(); //Set the export options to export to the format of choice. ExportOptions ObjExport = new ExportOptions(); ObjExport .setExportFormatType(ReportExportFormat.PDF); ReportExportControl oReportExportControl = new ReportExportControl(); //Pass the report source to the ReportExportControl and set the ExportOptions oReportExportControl.setReportSource(objReportSource); oReportExportControl.setExportOptions(ObjExport); //ExportAsAtttachment(true) prompts for open or save; false opens the report // in the speficied format after exporting. oReportExportControl.setExportAsAttachment(true); //Pass the ConnectionInfo to the report to set the database username and password oReportExportControl.setDatabaseLogonInfos(objConnectionInfos); //Pass Fields object to ReportExportControl oReportExportControl.setParameterFields(objFields); oReportExportControl.refresh(); oReportExportControl.setReuseParameterValuesOnRefresh(true); oReportExportControl.setOwnPage(true); oReportExportControl.setOwnForm(true); //Export the report oReportExportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
}catch(ReportSDKException e) { out.print(e); } %>
<%!
/* * Utility function to set values for the discrete parameters in the report. * The report parameter value is set and added to the Fields collection, * which can then be passed to the viewer so that the user is not prompted * for parameter values. * */ private void setDiscreteParameterValue(Fields oFields, String paramName, String reportName, Object value) { ParameterField oParameterField = new ParameterField(); oParameterField.setReportName(reportName); Values oValues = new Values(); ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue(); oParameterField.setName(paramName); oParameterFieldDiscreteValue.setValue(value); oValues.add(oParameterFieldDiscreteValue); oParameterField.setCurrentValues(oValues); oFields.add(oParameterField); } %> I'm unable to pass any values to reports.(i.e,UserName, Password,Parameter Value) Same coding working fine with Oracle.I'm getting problem while using MySQl. Suggest me which version of connector I have to use ?
I'm gettin while running, The Report you requested requires further Information. like User Name and Password..
Thanks in Advance!
Edited 1 time(s). Last edit at 04/09/2007 08:04A
|