Package com.jk.data.dynamic.paging
Class DataBasePager
java.lang.Object
com.jk.data.dynamic.paging.DataBasePager
- All Implemented Interfaces:
 DataPager
This class implements the 
DataPager interface to allow paging through
 database query results.
 It provides methods to query a database, retrieve the total number of rows, and navigate through pages of data.
- Version:
 - 1.0
 - Author:
 - Dr. Jalal H. Kiswani
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionintThis method gets the total number of rows in the data set.intThis method gets the current page number.intThis method gets the number of rows displayed on the current page.intThis method gets the total number of pages in the data set.getQuery()This method gets the SQL query used for retrieving data from the database.This method gets the cached query result set.static voidThis main method demonstrate the usage of this class.voidThis method moves to the first page in the data set.voidThis method moves to the last page in the data set.voidThis method moves to the next page in the data set.voidmoveToPage(int page) This method moves to a specific page in the data set.voidThis method moves to the previous page in the data set.voidsetDatasource(JKDataSource datasource) voidsetPageRowsCount(int pageRowsCount) This method sets the number of rows to be displayed on each page.voidThis method sets the SQL query to retrieve data from the database and calculates the number of pages based on the total row count and page size. 
- 
Constructor Details
- 
DataBasePager
public DataBasePager()This method constructs a newDataBasePager. 
 - 
 - 
Method Details
- 
main
This main method demonstrate the usage of this class.- Parameters:
 args- the command-line arguments.
 - 
getAllRowsCount
public int getAllRowsCount()This method gets the total number of rows in the data set.- Specified by:
 getAllRowsCountin interfaceDataPager- Returns:
 - the total number of rows in the data set.
 
 - 
getCurrentPage
public int getCurrentPage()This method gets the current page number.- Specified by:
 getCurrentPagein interfaceDataPager- Returns:
 - the current page number.
 
 - 
getPageRowsCount
public int getPageRowsCount()This method gets the number of rows displayed on the current page.- Specified by:
 getPageRowsCountin interfaceDataPager- Returns:
 - the number of rows on the current page.
 
 - 
getPagesCount
public int getPagesCount()This method gets the total number of pages in the data set.- Specified by:
 getPagesCountin interfaceDataPager- Returns:
 - the total number of pages.
 
 - 
getQuery
This method gets the SQL query used for retrieving data from the database.- Returns:
 - the SQL query.
 
 - 
getResultSet
This method gets the cached query result set.- Returns:
 - the the query result set.
 
 - 
moveToFirstPage
This method moves to the first page in the data set.- Specified by:
 moveToFirstPagein interfaceDataPager- Throws:
 PagingException- if an error occurs while navigating to the first page.
 - 
moveToLastPage
This method moves to the last page in the data set.- Specified by:
 moveToLastPagein interfaceDataPager- Throws:
 PagingException- if an error occurs while navigating to the last page.
 - 
moveToNextPage
This method moves to the next page in the data set.- Specified by:
 moveToNextPagein interfaceDataPager- Throws:
 PagingException- if an error occurs while navigating to the next page.
 - 
moveToPage
public void moveToPage(int page) This method moves to a specific page in the data set.- Specified by:
 moveToPagein interfaceDataPager- Parameters:
 page- Specifies the page number to move to.
 - 
moveToPreviousePage
This method moves to the previous page in the data set.- Specified by:
 moveToPreviousePagein interfaceDataPager- Throws:
 PagingException- if an error occurs while navigating to the previous page.
 - 
setDatasource
 - 
setPageRowsCount
public void setPageRowsCount(int pageRowsCount) This method sets the number of rows to be displayed on each page.- Specified by:
 setPageRowsCountin interfaceDataPager- Parameters:
 pageRowsCount- Specifies the new number of rows per page.
 - 
setQuery
This method sets the SQL query to retrieve data from the database and calculates the number of pages based on the total row count and page size.- Parameters:
 query- Specifies the SQL query.
 
 -