I have this code which I use on my swing application:
ReportClientDocument rpt = new ReportClientDocument();
rpt.open(reportPath+"APVendorList.rpt", 0);
rpt.getReportSource();
ReportViewerBean viewer = new ReportViewerBean();
viewer.init(new String[0], null, null, null);
//viewer.setHasGroupTree(false);
viewer.setReportSource(rpt.getReportSource());
The problem is that whenever I try to load the report using jframe, It always ask for login credentials:
Database Logon:
Server Name: Localhost
Database Name: <blank and cannot be edited>
User ID:
Password:
Is there a way to not type in those info eveytime I view the report? Or I could just pass java.sql.Connection to it? Also it seems like it doesnt know which database to connect to. Please help.
You can set the property values, something like this:
ReportClientDocument clientDoc = new ReportClientDocument();
....
DatabaseController dbController=clientDoc.getDatabaseController();
IConnectionInfo ConnInfo = dbController.getConnectionInfos(null).getConnectionInfo(0);
com.crystaldecisions.sdk.occa.report.lib.PropertyBag boPropertyBag1 = new com.crystaldecisions.sdk.occa.report.lib.PropertyBag();
// Set the properties for the connection
boPropertyBag1.put("JDBC Connection String", connString);
boPropertyBag1.put("Database Class Name", dbClassName);
boPropertyBag1.put("Connection URL", connString);
boPropertyBag1.put("Server", serverHost);
....
// Assign the properties to the connection info
ConnInfo.setAttributes(boPropertyBag1);
// Set the DB Username and Pwd
ConnInfo.setUserName(usrName);
ConnInfo.setPassword(pwd);
Hope this helps...