#### Example 3: Developing reports from Java object data source UDS

The JReport Designer UDS can use any Java object as a data source for you to create reports. To implement this function, JReport Designer provides a class UDSForJavaBean, in which the getResultSet() method creates instances for the interface JavaBeanDataProvider, and then uses the method init() to initialize the data of the created instances.

Below is the Java code for class definition:

    public class UDSForJavaBean implements JRUserDataSource {
            // Define data.
            public ResultSet getResultSet(String param)
                            throws JRUserDataSourceException {
                    // Method body.
            }

            /**
             * Free the resources such as : Connection, Statement, ResultSet.
             */
            public void releaseResultSet() throws JRUserDataSourceException {
                    // Method body.
            }
    }

The interface JavaBeanDataProvider is defined as follows:

    public interface JavaBeanDataProvider
        {
        public void init(String dataID, Properties initprops)
                      throws JavaBeanDataProviderException;
             public Class getMetadataJavaBean()
                      throws ClassNotFoundException;
             public Object next() throws JavaBeanDataProviderException;
             public boolean requireDetails(String collectionPropName);
             public int getMaxShareTimes(String collectionPropName);
             public int getTimeoutForSubCollection(String collectionPropName);
             public void exit()throws JavaBeanDataProviderException;
            }

For examples of how to create reports using the Java object data interface, JReport provides you with two demos which are in UDSForJavaBean.zip in `<install_root>\help\designer\samples`. All the classes and interfaces the demos require are also compressed in UDSForJavaBean.zip.

- Demo 1: Creating reports from simple Java object UDS
- Demo 2: Creating reports from Java object UDS with multi-levels of collections