User data source API

As a database application, JReport Designer can access data stored in a database through a JDBC connection. However, through the user data source API, JReport Designer can also access data from an external data source, such as a text file, or Lotus Notes, which is not stored in a database, or when there is no JDBC driver available.

The UDS API is a part of the JReport Data Access Model as shown in this diagram:

The user data source API:

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:

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

Reference: JReport Javadoc jet.datasource.JRUserDataSource class in <install_root>\help\api.

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 need 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 Add User Defined Data Source dialog.

Examples of using the UDS API

The user data source 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.