⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jrcviewreportlogon.java

📁 java实现水晶报表
💻 JAVA
字号:
/**
 * Applies to: XI Release 2.
 * Date Created: October 2005.
 * Description: This sample demonstrates how to set the report's database logon credentials before viewing a report.
 * 				NOTE: If the report's datasource is based off a secured database, then database logon credentials need 
 * 				to be set before the report can be viewed or exported.      
 * Author: CW. 
 */

//Crystal Java Reporting Component (JRC) imports.
import com.crystaldecisions.reports.sdk.*;
import com.crystaldecisions.sdk.occa.report.lib.*;

//Java Imports.
import javax.swing.*;

public class JRCViewReportLogon {

	private static final String REPORT_NAME = "JRCViewReportLogon.rpt";
	
	//Database credentials for the report's datasource.
	private static final String USERNAME = "vantech";
	private static final String PASSWORD = "vantech";
	
	public static void launchApplication() {
		
		try {
										
			//Open report.
			ReportClientDocument reportClientDoc = new ReportClientDocument();
			reportClientDoc.open(REPORT_NAME, 0);
						
			//Set the logon information for each table in the report.  This logon will be applied to all
			//of the database connections used in the report.  If the report requires different login credentials
			//for each connection in the report, then the connection info for each table in the report must be
			//set with the appropriate database logon credentials.  If the subreport connects to the same datasource as the
			//main report (i.e., as this sample's RPT file is), setting the database credentials with the logon() method below will be sufficient for the subreport 
			//as well.  If the datasource for the subreport(s) are different from the main report, use the SubreportClientDocument's
			//DatabaseController to set the logon credentials appropriately.
			reportClientDoc.getDatabaseController().logon(USERNAME, PASSWORD);
						
			//Launch JFrame that contains the report viewer.
			new ReportViewerFrame(reportClientDoc);		
			
		}
		catch(ReportSDKException ex) {	
			System.out.println(ex);
		}
		catch(Exception ex) {
			System.out.println(ex);			
		}
		
	}
	
	public static void main(String [] args) {
		
		//Event-dispatching thread to run Swing GUI.  This is good practice for Swing applications
		//to help ensure that events are dispatched in a predicatable order. 
		//For more information on using this method, refer to the SUN site below for more details:
		//http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
		SwingUtilities.invokeLater(new Runnable() { 
			public void run() {
				//Hand-off to worker function to start application.
				launchApplication();				
			}
		});
					
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -