Java 更改crystal报表中的数据库连接
我正在jsp中使用水晶报表。当我在SAP crystal report中设计报表时,我设置了数据库连接。现在我想在呈现报表时更改连接字符串。连接字符串从web.xml获取,任何配置或编程方式 这是我的项目结构Java 更改crystal报表中的数据库连接,java,c#,jsp,crystal-reports,sap,Java,C#,Jsp,Crystal Reports,Sap,我正在jsp中使用水晶报表。当我在SAP crystal report中设计报表时,我设置了数据库连接。现在我想在呈现报表时更改连接字符串。连接字符串从web.xml获取,任何配置或编程方式 这是我的项目结构 <%@ page import= "com.crystaldecisions.report.web.viewer.*,com.crystaldecisions.sdk.occa.report.data.*" %> <%@ page import="com.crystald
<%@ page import= "com.crystaldecisions.report.web.viewer.*,com.crystaldecisions.sdk.occa.report.data.*" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.lib.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.*"%>
<%@page import="com.crystaldecisions.reports.sdk.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>
<%
//open the report rpt file
String REPORT_NAME = "test_table.rpt";
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(REPORT_NAME, 0);
//set up a viewer
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setOwnPage(true);
viewer.setOwnForm(true);
viewer.setPrintMode(CrPrintMode.ACTIVEX);
//pass it the report source
viewer.setReportSource(reportClientDoc.getReportSource());
//Render the report.
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
%>
my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Report_Viewer</display-name>
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>/crystalreportviewers</param-value>
</context-param>
<context-param>
<param-name>crystal_image_use_relative</param-name>
<param-value>webapp</param-value>
</context-param>
<servlet>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<servlet-class>com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<url-pattern>/CrystalReportViewerHandler</url-pattern>
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/IntranetDBW</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
报表查看器
水晶图片
/晶体报告查看器
水晶图像使用相对
网络应用
CrystalReportViewerServlet
com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet
CrystalReportViewerServlet
/CrystalReportViewerHandler
jdbc/IntranetDBW
javax.sql.ConnectionPoolDataSource
容器
可分享
index.jsp
我的jsp
<%@ page import= "com.crystaldecisions.report.web.viewer.*,com.crystaldecisions.sdk.occa.report.data.*" %>
<%@ page import="com.crystaldecisions.sdk.occa.report.lib.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.*"%>
<%@page import="com.crystaldecisions.reports.sdk.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>
<%
//open the report rpt file
String REPORT_NAME = "test_table.rpt";
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(REPORT_NAME, 0);
//set up a viewer
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setOwnPage(true);
viewer.setOwnForm(true);
viewer.setPrintMode(CrPrintMode.ACTIVEX);
//pass it the report source
viewer.setReportSource(reportClientDoc.getReportSource());
//Render the report.
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
%>