SAP Knowledge Base Article - Public

1203279 - Null Pointer Exception in CRJ when using Command Object with Parameter for dynamic database connection


  • A Crystal Report is designed using Command Object with parameter.
  • When attempting to change the datasource at runtime using ITable object of Crystal Reports for Java you are getting the following exception:

"Null Pointer Exception"


Occurs in Crystal Reports for Eclipse 1.0 and 2.0.


  • ITable sets the parameter for the command object after changing the table location.
  • Thus it contacting the destination datasource without any parameter and generates a "Null Pointer" exception.


  • Use the IProcedure Object, which is included in the CRJ SDK.
  • It is used for both stored procedures and command objects, and has a method to get and set the parameter values before changing the datasource.
  • IProcedure object is documented in the RAS API documentation, which is available for the CRJ as well.
  • Below is a snippet that indicates how to use the iProcedure object on a command table in your report:
ITable table = tables.getTable(i);

if(table instanceof
           IProcedure command = (IProcedure)table;
           ParameterField commandParam = (ParameterField) command.getParameters().get(0);
           Values values = new Values();
           ParameterFieldDiscreteValue pfdv = new ParameterFieldDiscreteValue();


Null Pointer Exception after using Command Object with Parameter for dynamic database connection in the JRC thick client application , 6712056 , KBA , BI-DEV-JAV , BI Software Development Kits (SDKs) - Java , How To


Crystal Reports, version for Eclipse 1.0 ; Crystal Reports, version for Eclipse 2.0