on 09-23-2008 8:09 PM
Hi,
I am using BO XI2 SP1 RAS (managed report) API, I am trying to modify ReportDocument's database info and parameters RUNTIME.
I am getting following error
com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Failed to open the connection.
Failed to open the connection.
C:\WINDOWS\TEMP\{00F396A0-966B-41F5-8925-55632CCC94A1}.rpt---- Error code:-2147482892 Error code name:failed
at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.s.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.z.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ak.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ad.int(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.bk.for(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.v.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.v.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setTableLocation(Unknown Source)
what does above error means and I am getting errror on the line databaseController.setTableLocation(originalTable, newTable);
Is anybody having Sample Code RAS with JDBC - what all property needs to be set with RAS API?, please let me know.
Thanks,
Rupesh
Edited by: Rupesh Raut on Sep 24, 2008 9:15 PM
Hi Rupesh
Here is the Sample jsp Code for RAS with JDBC to change the database location at runtime.
<%@ page import = "com.crystaldecisions.sdk.plugin.desktop.report.*"
import = "com.crystaldecisions.sdk.occa.report.data.*"
import = "com.crystaldecisions.sdk.occa.report.application.*"
import = "com.crystaldecisions.sdk.plugin.desktop.common.IReportLogon"
import = "com.crystaldecisions.sdk.properties.ISDKList"
import = "com.crystaldecisions.sdk.properties.ISDKSet"
import = "com.crystaldecisions.sdk.plugin.desktop.common.IReportTablePrefix"
import = "java.util.Iterator,com.crystaldecisions.sdk.occa.report.data.*"
import = "com.crystaldecisions.sdk.occa.report.application.ReportClientDocument"
import = "com.crystaldecisions.sdk.occa.report.application.OpenReportOptions"
import = "com.crystaldecisions.sdk.occa.report.reportsource.IReportSource"
import = "com.crystaldecisions.sdk.occa.managedreports.*"
import = "java.util.Locale"
import = "com.crystaldecisions.sdk.occa.report.lib.*"
import = "com.crystaldecisions.report.web.viewer.*"
import = "com.crystaldecisions.sdk.framework.*"
import = "com.crystaldecisions.sdk.occa.infostore.*"
%>
<html>
<head>
<title>Simple Table Location - JDBC</title>
</head>
<%
String mUser = "Administrator"; // User Name
String mPassword = ""; // Password
String mCMSName = "boxir2sp2";
String mAuthType = "secEnterprise"; // Authorization Type
String reportName = "Dynamic_WithoutChange";
String dbUID = "sa"; // Userid for new sql database
String dbPWD = ""; // Password for new sql database
// ========= CONNECTION INFO VALUES =========
String conn_url = "jdbc:sybase:Tds:D3279W2K3CR2:5000/model";
String db_class_name = "com.sybase.jdbc2.jdbc.SybDriver";
String default_behaviour = "Sybase";
String conn_string="!com.sybase.jdbc2.jdbc.SybDriver!jdbc:sybase:Tds:D3279W2K3CR2:5000/model;DatabaseName=;user=;password=!ServerType=1!QuoteChar=\"";
String data_source = "";
String db = "model";
String server = "D3279W2K3CR2";
String trusted_conn = "false";
String use_jdbc = "true";
System.out.println("start");
// ========= LOGON TO CMS =========
CrystalEnterprise ce = new CrystalEnterprise();
ISessionMgr sm = ce.getSessionMgr();
IEnterpriseSession es = sm.logon(mUser, mPassword, mCMSName, mAuthType);
// Get the Report Application Factory service from Crystal Enterprise
IReportAppFactory rptAppFactory = (IReportAppFactory)es.getService("", "RASReportService");
// Get the InfoStore service from Crystal Enterprise
IInfoStore iStore = (IInfoStore)es.getService("", "InfoStore");
// Query infostore for InfoObject
IInfoObjects oInfoObjects = iStore.query("Select * from CI_INFOOBJECTS Where SI_INSTANCE=0 And SI_NAME='" + reportName + "'");
// Get a reference to the InfoObject object
IInfoObject oInfoObject = (IInfoObject) oInfoObjects.get(0);
IReportAppFactory reportAppFactory = (IReportAppFactory) es.getService("","RASReportFactory");
// Get reportclientdocument object
ReportClientDocument clientDoc = reportAppFactory.openDocument(oInfoObject, OpenReportOptions._openAsReadOnly , Locale.ENGLISH);
// ========= NEW CONNECTION INFO OBJECT =========
// Create connectionInfo and Property bag objects
ConnectionInfo ci = (ConnectionInfo) clientDoc.getDatabaseController().getConnectionInfos(new PropertyBag()).getConnectionInfo(0);
// Set new ConnectionInfo properties
PropertyBag logonPb = new PropertyBag();
logonPb.put("Connection URL", conn_url);
logonPb.put("Database Class Name", db_class_name);
logonPb.put("Generic JDBC Driver Behavior", default_behaviour);
logonPb.put("JDBC Connection String", conn_string);
logonPb.put("JNDI DataSource Name", data_source);
logonPb.put("Server", server);
logonPb.put("Database", db);
logonPb.put("Trusted_Connection", trusted_conn);
logonPb.put("Use JDBC", use_jdbc);
PropertyBag pb = ci.getAttributes();
// Set the connection info objects members
// 1. Pass the Logon Properties to the main PropertyBag
// 2. Set the Server Description tpo the new JDBC connection string
pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_jdbc.dll");
pb.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, logonPb);
pb.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, server);
pb.put(PropertyBagHelper.CONNINFO_CRQE_DATABASETYPE, "JDBC (JNDI)");
// Set the connectionInfo attribute to the PropertyBag
ci.setAttributes(pb);
// Set Username and Password for this connection
ci.setUserName(dbUID);
ci.setPassword(dbPWD);
// Set the Kind of connection. CRQE (Crystal Reports Query Engine) type
ci.setKind(ConnectionInfoKind.CRQE);
// ========= SET NEW CONNECTION INFO TO TABLES =========
Tables tables = clientDoc.getDatabaseController().getDatabase().getTables();
for (int x=0;x<tables.size();x++) {
Table oldTable = (Table) clientDoc.getDatabaseController().getDatabase().getTables().getTable(x);
Table newTable = (Table) oldTable.clone(true);
newTable.setName( "Inventory" );//Inventory is new table name
newTable.setAlias( "Employee" );//Employee is new table Alias
newTable.setQualifiedName( "model.dbo.Inventory" );
//newTable.setQualifiedName(oldTable.getQualifiedName());
//newTable.setAlias(oldTable.getAlias());
//newTable.setName(oldTable.getName());
newTable.setConnectionInfo(ci);
clientDoc.getDatabaseController().setTableLocation(oldTable, newTable);
}
// Verify database
clientDoc.verifyDatabase();
// ========= VIEW REPORT =========
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setEnterpriseLogon(es);
viewer.setName("Crystal_Report_Viewer");
viewer.setOwnPage(true);
//viewer.setReportSource(reportSource);
viewer.setReportSource(clientDoc.getReportSource());
// Store viewer object in session
session.setAttribute( "crViewer", viewer);
response.sendRedirect( "viewer.jsp" );
%>
Hope this helps you.
Thanks
Soni
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.