Hi,
I am trying to use stored procedure in the crystal report, that comes bundled with RAD7. The following code I got from http://diamond.businessobjects.com/node/520 for using the stored procedure. I am getting 'UnexpectedQueryEngineError' on JRCCommunicationAdapter when trying to establish data connection to add the stored procedure to the report. I tried the same example above for adding table to the report by modifying 'Procedure' to 'Table' and it worked fine.
I really need to use the stored procedure in the report and get to have this working soon. Immediate help is greatly appreciated.
import java.io.IOException;
import com.crystaldecisions.sdk.occa.report.application.DatabaseController;
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
import com.crystaldecisions.sdk.occa.report.data.ConnectionInfo;
import com.crystaldecisions.sdk.occa.report.data.DBField;
import com.crystaldecisions.sdk.occa.report.data.FieldValueType;
import com.crystaldecisions.sdk.occa.report.data.Fields;
import com.crystaldecisions.sdk.occa.report.data.Table;
import com.crystaldecisions.sdk.occa.report.data.Procedure;
import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;
import com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class AddSampleProcedure {
public static void main(String[] args) throws ReportSDKException, IOException {
ReportClientDocument clientDoc = new ReportClientDocument();
clientDoc.setReportAppServer("inproc:jrc");
// Open report
clientDoc.newDocument();
DatabaseController ctr = clientDoc.getDatabaseController ();
Procedure table = new Procedure (); //Table table = new Table();
String tableName = "Welcome"; //tableName = "Product";
table.setAlias (tableName);
table.setName (tableName);
table.setQualifiedName (tableName);
table.setDescription (tableName);
/*Fields fields = new Fields ();
DBField field = new DBField ();
String fieldName = "product_name";
field.setDescription (fieldName);
field.setHeadingText (fieldName);
field.setName (fieldName);
field.setType (FieldValueType.stringField);
field.setLength(255);
fields.add (field);
table.setDataFields (fields);*/
String ServerName = serverName;
String DatabaseName = dbName;
String JDBC_URL=jdbcURL;
String JDBC_Class = "oracle.jdbc.driver.OracleDriver";
String UserName = userName;
String Password = password;
PropertyBag attrs = new PropertyBag();
attrs.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_jdbc.dll");
attrs.put(PropertyBagHelper.CONNINFO_SERVER_NAME, ServerName);
attrs.put(PropertyBagHelper.CONNINFO_DATABASE_NAME, DatabaseName);
attrs.put(PropertyBagHelper.CONNINFO_SERVER_TYPE, "JDBC (JNDI)");
attrs.put(PropertyBagHelper.CONNINFO_JDBC_DATABASECLASSNAME, JDBC_Class);
attrs.put(PropertyBagHelper.CONNINFO_JDBC_CONNECTION_URL, JDBC_URL);
ConnectionInfo info = new ConnectionInfo ();
info.setAttributes (attrs);
info.setUserName(UserName);
info.setPassword(Password);
table.setConnectionInfo (info);
ctr.addTable (table, null);
clientDoc.saveAs("AddProcedure.rpt", "C:/Test", 1);
System.out.println("Done");
}
}
Thanks in advance,
Lakshmi