Creating a scripted data source and a non-scripted data source are similar tasks. The differences between creating a scripted data source and a non‑scripted data source are:
The scripted data source must be selected from the list of data source types when creating a scripted data source.
Two event handler methods, open( ) and close( ), are available only for a scripted data source.
Every scripted data source must have at least one scripted data set. The differences between creating a scripted data set and a non-scripted data set are:
The scripted data set must be associated with a scripted data source.
The code for the scripted data set fetch( ) event handler method must be provided.
There is a different dialog for identifying the columns of a scripted data set.
When using BIRT Report Designer to create a scripted data source, the following tasks must be performed:
Create a scripted data source.
Right-click on Data Sources in Data Explorer and select Scripted Data Source in the list of data source types.
Create a scripted data set.
Right-click on Data Sets in Data Explorer and select a scripted data source from the list of available data sources.
Define output columns.
Define the names and types of output columns, using the scripted data set editor.
Supply code for the data source open( ) and close( ) methods.
There are two scripted data source event handler methods, open( ) and close( ). It is not mandatory to implement either method, but most applications require the use of the open( ) method to initialize a data source. Typically, you create a Java object for accessing the data source in the open( ) method.
Use the close( ) method to clean up any loose ends, including setting object references to null to ensure that the objects are deleted during garbage collection.
Supply code for the data set methods.
There are three scripted data set event handler methods, open( ), fetch( ), and close( ). Implementing the fetch( ) method is mandatory to initialize variables and to prepare the data source for fetching data.
Use the fetch( ) method to get a row of data from the data source and to populate the columns of the row object. The fetch( ) method must return either true or false. A true value tells BIRT that there is another row to process. A false return value signifies that there are no more rows to process.
Use the close( ) method to perform clean‑up operations.
Place the columns on the report layout.
Place a data set column on a report layout the same way you place a column for a non-scripted data set.
The following tutorial guides you through the procedure required to perform each task in this process.