你好
由于我们设计的报表在实际使用过程中数据量巨大,因此打开报表要花费很长的时间。为了解决这个问题,我们决定采用将数据集合分批给报表显示的方法。在使用过程中让报表文件不执行报表文件里面的sql语句,而是将分批的sql语句单独执行,执行的结果ResultSet再给报表显示。现在的问题是在调用DatabaseController类中的
void
setDataSource(java.sql.ResultSet data, java.lang.String oldTableAlias, java.lang.String newTableName)
方法时候,这个方法将数据库中所有的Number型字段的第一位数字换成了“$”符号。实际上请问这个问题怎样解决?
这是源程序:
<%@ page import="com.crystaldecisions.sdk.occa.report.application.*,
com.crystaldecisions.sdk.occa.report.data.*,
com.crystaldecisions.sdk.occa.report.lib.*,
java.sql.*"
%>
<html>
<head>
<title>Simple SQL Query String</title>
</head>
<body>
<%
/*=============================================================================================
WORKING WITH THE REPORT APPLICATION SERVER AND JSP TO USE JAVA.SQL.RESULTSET AS THE DATASOURCE
===============================================================================================
ALWAYS REQUIRED STEPS
- Create a new Report Application Session
- Create a Report Application Server (RAS) Service
- Set the RAS Server to be used for the service
- Initialize the RAS Service
- Create the report client document object
- Set the RAS Server to be used for the report client document
- Open the report, and set the open type to Read Only
CREATE THE JDBC-ODBC BRIDGE AND RETRIEVE A JAVA.SQL.RESULTSET
- Create class for JDBC:ODBC bridge
- Construct connection object
- Construct statement object
- Construct result set through SQL query ( Select all Customers and their Last Years Sales where Sales is greater than 20000$ )
PASS THE JAVA.SQL.RESULTSET TO THE REPORT THROUGH THE DATABASE CONTROLLER
- Set the datasource for the report to the java.sql.ResultSet through the Database Controller
INSTANTIATE THE REPORT VIEWER
- Create a Viewer object
- Set the source for the viewer to the client documents report source
- Process the http request to view the report
- Dispose of the viewer object
==================================================================*/
// Specify the report to be opened
String reportName ="SimpleSQLQueryString.rpt";
%>
<%
/* ALWAYS REQUIRED STEPS
- Create a new Report Application Session
- Create a Report Application Server (RAS) Service
- Set the RAS Server to be used for the service
- Initialize the RAS Service
- Create the report client document object
- Set the RAS Server to be used for the report client document
- Open the report, and set the open type to Read Only
*/
// Create a new Report Application Session
ReportAppSession ra = new ReportAppSession();
// Create a Report Application Server Service
ra.createService("com.crystaldecisions.sdk.occa.report.application.ReportClientDocument");
// Set the RAS Server to be used for the service
ra.setReportAppServer("127.0.0.1");
// Initialize RAS
ra.initialize();
// Create the report client document object
ReportClientDocument clientDoc = new ReportClientDocument();
// Set the RAS Server to be used for the Client Document
clientDoc.setReportAppServer(ra.getReportAppServer() );
// Open the report, and set the open type to Read Only
clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
%>
<%
// CREATE THE JDBC-ODBC BRIDGE AND RETRIEVE A JAVA.SQL.RESULTSET
// Create class for JDBC:ODBC bridge
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Construct connection
java.sql.Connection connection = DriverManager.getConnection("jdbc:odbc:Xtreme Sample Database 9", "Admin", "");
// Construct statement
Statement statement = connection.createStatement();
// Construct result set through query ( Select all Customers and their Last Years Sales where Sales is greater than 20000$ )
ResultSet results = statement.executeQuery("Select Customer.`Customer Name`, Customer.`Last Year's Sales` from Customer where Customer.`Last Year's Sales` > 20000");
// PASS THE JAVA.SQL.RESULTSET TO THE REPORT THROUGH THE DATABASE CONTROLLER
// Set the datasource for the report to the java.sql.ResultSet through the Database Controller
clientDoc.getDatabaseController().setDataSource(results,
clientDoc.getDatabase().getTables().getTable(0).getName(),
"Reports");
%>
<%
CrystalReportInteractiveViewer viewer = new CrystalReportInteractiveViewer();
// Set the name for the interactive viewer
viewer.setName("Crystal_Report_Interactive_Viewer");
// Set the viewer to its own form
viewer.setOwnForm(true);
// Ste the viewer to own the page
viewer.setOwnPage(true);
//Set the source for the interacive viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());
// Process the http request to view the report
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
// Dispose of the viewer object
viewer.dispose();
%>
</body>
</html>
void
setDataSource(java.sql.ResultSet data, java.lang.String oldTableAlias, java.lang.String newTableName)
方法时候,这个方法将数据库中所有的Number型字段的第一位数字换成了“$”符号。实际上请问这个问题怎样解决?
这是源程序:
<%@ page import="com.crystaldecisions.sdk.occa.report.application.*,
com.crystaldecisions.sdk.occa.report.data.*,
com.crystaldecisions.sdk.occa.report.lib.*,
java.sql.*"
%>
<html>
<head>
<title>Simple SQL Query String</title>
</head>
<body>
<%
/*=============================================================================================
WORKING WITH THE REPORT APPLICATION SERVER AND JSP TO USE JAVA.SQL.RESULTSET AS THE DATASOURCE
===============================================================================================
ALWAYS REQUIRED STEPS
- Create a new Report Application Session
- Create a Report Application Server (RAS) Service
- Set the RAS Server to be used for the service
- Initialize the RAS Service
- Create the report client document object
- Set the RAS Server to be used for the report client document
- Open the report, and set the open type to Read Only
CREATE THE JDBC-ODBC BRIDGE AND RETRIEVE A JAVA.SQL.RESULTSET
- Create class for JDBC:ODBC bridge
- Construct connection object
- Construct statement object
- Construct result set through SQL query ( Select all Customers and their Last Years Sales where Sales is greater than 20000$ )
PASS THE JAVA.SQL.RESULTSET TO THE REPORT THROUGH THE DATABASE CONTROLLER
- Set the datasource for the report to the java.sql.ResultSet through the Database Controller
INSTANTIATE THE REPORT VIEWER
- Create a Viewer object
- Set the source for the viewer to the client documents report source
- Process the http request to view the report
- Dispose of the viewer object
==================================================================*/
// Specify the report to be opened
String reportName ="SimpleSQLQueryString.rpt";
%>
<%
/* ALWAYS REQUIRED STEPS
- Create a new Report Application Session
- Create a Report Application Server (RAS) Service
- Set the RAS Server to be used for the service
- Initialize the RAS Service
- Create the report client document object
- Set the RAS Server to be used for the report client document
- Open the report, and set the open type to Read Only
*/
// Create a new Report Application Session
ReportAppSession ra = new ReportAppSession();
// Create a Report Application Server Service
ra.createService("com.crystaldecisions.sdk.occa.report.application.ReportClientDocument");
// Set the RAS Server to be used for the service
ra.setReportAppServer("127.0.0.1");
// Initialize RAS
ra.initialize();
// Create the report client document object
ReportClientDocument clientDoc = new ReportClientDocument();
// Set the RAS Server to be used for the Client Document
clientDoc.setReportAppServer(ra.getReportAppServer() );
// Open the report, and set the open type to Read Only
clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
%>
<%
// CREATE THE JDBC-ODBC BRIDGE AND RETRIEVE A JAVA.SQL.RESULTSET
// Create class for JDBC:ODBC bridge
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Construct connection
java.sql.Connection connection = DriverManager.getConnection("jdbc:odbc:Xtreme Sample Database 9", "Admin", "");
// Construct statement
Statement statement = connection.createStatement();
// Construct result set through query ( Select all Customers and their Last Years Sales where Sales is greater than 20000$ )
ResultSet results = statement.executeQuery("Select Customer.`Customer Name`, Customer.`Last Year's Sales` from Customer where Customer.`Last Year's Sales` > 20000");
// PASS THE JAVA.SQL.RESULTSET TO THE REPORT THROUGH THE DATABASE CONTROLLER
// Set the datasource for the report to the java.sql.ResultSet through the Database Controller
clientDoc.getDatabaseController().setDataSource(results,
clientDoc.getDatabase().getTables().getTable(0).getName(),
"Reports");
%>
<%
CrystalReportInteractiveViewer viewer = new CrystalReportInteractiveViewer();
// Set the name for the interactive viewer
viewer.setName("Crystal_Report_Interactive_Viewer");
// Set the viewer to its own form
viewer.setOwnForm(true);
// Ste the viewer to own the page
viewer.setOwnPage(true);
//Set the source for the interacive viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());
// Process the http request to view the report
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
// Dispose of the viewer object
viewer.dispose();
%>
</body>
</html>
浙公网安备 33010602011771号