BackPrevious Page Next PageNext

User Data Source API

Introduction to the UDS API

UDS API interface

JDBC API used by UDS

Examples of using the UDS API

Introduction to the UDS API

The User Data Source API is a part of the JReport Data Access Model as shown in the following diagram. It is:

JReport Data Access Model diagram

Through the UDS API, JReport Designer can access data from an external data source, such as a text file, or Excel file, which is not stored in a database, or when there is no JDBC driver available.

Notes:

UDS API interface

To use the UDS API, the interface jet.datasource.JRUserDataSource must be implemented, and the class definition may be as follows. For detailed information, see the JReport Javadoc jet.datasource.JRUserDataSource class in <install_root>\help\api.

import jet.datasource.*;
public class UserUDS 
    implements JRUserDataSource
{
    // Class body.
} 

The following are methods of the interface:

Public java.sql.ResultSet getResultSet(String strParam) throws JRUserDataSourceException

This method gets the result set for user data source.

Public void releaseResultSet() throws JRUserDataSourceException

This method frees the ResultSet object.

JDBC API used by UDS

In order to get data from user defined data source, JReport needs to invoke the following JDBC API (for details about the API, refer to http://java.sun.com/javase/6/docs/api/).

java.sql.ResultSet

java.sql.ResultSetMetaData

Note: The method ResultSetMetaData getMetaData() throws SQLException is only invoked when the Specify Columns option is not checked in the New User Defined Data Source dialog.

Examples of using the UDS API

The UDS API is flexible and convenient to use. Before you implement it, you should first make an overall consideration of the architecture. JReport provides you with several scenarios which use the JReport UDS API. You can refer to them for assistance.

BackPrevious Page Next PageNext