Docmosis API 4.5.0

com.docmosis.template.population
Class SimpleSQLDataProviderPopulator

java.lang.Object
  extended bycom.docmosis.template.population.SimpleSQLDataProviderPopulator

public class SimpleSQLDataProviderPopulator
extends Object

A class responsible for populating a data provider given an SQL Result Set.
This data provider populator simply mirrors a result set, so that each field in the result set will be one field in the resulting data provider. Each field in the data provider will have a number of indexes equal to the number or rows in the result set.
All of the data is contained inside one data provider, with no children data providers involved.
It is recommended that you use the GroupedSQLDataProviderPopulator instead, unless you are doing some simple (single-row) data population.
If an SQL query returns 5 rows, with a number of fields including one called "description", the 5th row's description field can be retrieved from the resulting data provider by calling the following:

 dp.getString("description", 4);
 

See Also:
GroupedSQLDataProviderPopulator

Method Summary
static void populateDataProvider(MutableDataProvider mdp, ResultSet results, String dpRowName)
          Get the grid-like data provider populated by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

populateDataProvider

public static void populateDataProvider(MutableDataProvider mdp,
                                        ResultSet results,
                                        String dpRowName)
                                 throws SQLException
Get the grid-like data provider populated by this class. The data provider will be in the following shape:
 (main-data-provider) ---+--- (row-data-provider[0]) (field-1) (field-2) ... (field-n)
                         |
                         +--- (row-data-provider[1]) (field-1) (field-2) ... (field-n)
                         |
                         |
                        ...
                         |
                         +--- (row-data-provider[i]) (field-1) (field-2) ... (field-n)
 
An example of how to access a string from a field called "myField" from the third row where the rows are called "myRow", would be:
 dataProvider.getDataProvider("myRow", 2).getString("myField");

Parameters:
mdp - the data provider to populate.
results - the result set of an SQL Query.
dpRowName - the name of the data provider for each row in the result set.
Throws:
SQLException - if something goes wrong reading the result set.

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.