Network Deployment (Distributed operating systems), v8.0 > Reference > Developer detailed usage information
JDBC mediator paging
Paging can be useful for moving through large data sets because it can limit the amount of data pulled into memory at any given time. The JDBC DMS API provides two interfaces that implement paging.
If the metadata provided to the data mediator service (DMS) defines customers and the page size is set to ten, then the first page is a DataGraph containing the first ten customer DataObjects. The next page is another DataGraph with the next ten Customers, and so forth.
One thing to note is that the JDBC DMS provides paging at the root of the graph. That is, there is no restriction on the number of related DataObjects returned. For example, if the metadata provided to the DMS defines customers and related orders, it is the customers that are paged. If the page size is set to ten, then the first page is a graph with the first 10 customers and all related orders for each customer.
There are two interfaces provided by the DMS that you can take advantage of, the Pager and the CountingPager. The Pager interface provides a cursor-like next() method capability. The next() function returns a graph representing the next page of data from the entire data set specified by the mediator metadata. There is also a previous() function available with the same capabilities, only going backward. The CountingPager interface enables you to retrieve a specific page number. The following example illustrates paging through a large set of customer instances using a CountingPager interface with a maximum of 5 DataObjects from the root table per page.
CountingPager pager = PagerFactory.soleInstance.createCountingPager(5); int count = pager.pageCount(mediator); for (int i = 1, i <= count, i++) { DataObject graph = pager.page(i, mediator); // Iterate through all returned customers in the // current page. Iterator iter = graph.getList("CUSTOMER").iterator(); while (iter.hasNext()) { DataObject cust = (DataObject) iter.next(); System.out.println(cust.getString("CUSTFIRS NAME")); } }If you try to move before the first page or after the last available page, a JDBC mediator exception occurs.
Java DataBase Connectivity Mediator Service