Class DataBasePager

java.lang.Object
com.jk.data.dynamic.paging.DataBasePager
All Implemented Interfaces:
DataPager

public class DataBasePager extends Object implements 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
    Constructor
    Description
    This method constructs a new DataBasePager.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This method gets the total number of rows in the data set.
    int
    This method gets the current page number.
    int
    This method gets the number of rows displayed on the current page.
    int
    This method gets the total number of pages in the data set.
    This method gets the SQL query used for retrieving data from the database.
    This method gets the cached query result set.
    static void
    main(String[] args)
    This main method demonstrate the usage of this class.
    void
    This method moves to the first page in the data set.
    void
    This method moves to the last page in the data set.
    void
    This method moves to the next page in the data set.
    void
    moveToPage(int page)
    This method moves to a specific page in the data set.
    void
    This method moves to the previous page in the data set.
    void
    void
    setPageRowsCount(int pageRowsCount)
    This method sets the number of rows to be displayed on each page.
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DataBasePager

      public DataBasePager()
      This method constructs a new DataBasePager.
  • Method Details

    • main

      public static void main(String[] args)
      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:
      getAllRowsCount in interface DataPager
      Returns:
      the total number of rows in the data set.
    • getCurrentPage

      public int getCurrentPage()
      This method gets the current page number.
      Specified by:
      getCurrentPage in interface DataPager
      Returns:
      the current page number.
    • getPageRowsCount

      public int getPageRowsCount()
      This method gets the number of rows displayed on the current page.
      Specified by:
      getPageRowsCount in interface DataPager
      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:
      getPagesCount in interface DataPager
      Returns:
      the total number of pages.
    • getQuery

      public String getQuery()
      This method gets the SQL query used for retrieving data from the database.
      Returns:
      the SQL query.
    • getResultSet

      public CachedRowSet getResultSet()
      This method gets the cached query result set.
      Returns:
      the the query result set.
    • moveToFirstPage

      public void moveToFirstPage() throws PagingException
      This method moves to the first page in the data set.
      Specified by:
      moveToFirstPage in interface DataPager
      Throws:
      PagingException - if an error occurs while navigating to the first page.
    • moveToLastPage

      public void moveToLastPage() throws PagingException
      This method moves to the last page in the data set.
      Specified by:
      moveToLastPage in interface DataPager
      Throws:
      PagingException - if an error occurs while navigating to the last page.
    • moveToNextPage

      public void moveToNextPage() throws PagingException
      This method moves to the next page in the data set.
      Specified by:
      moveToNextPage in interface DataPager
      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:
      moveToPage in interface DataPager
      Parameters:
      page - Specifies the page number to move to.
    • moveToPreviousePage

      public void moveToPreviousePage() throws PagingException
      This method moves to the previous page in the data set.
      Specified by:
      moveToPreviousePage in interface DataPager
      Throws:
      PagingException - if an error occurs while navigating to the previous page.
    • setDatasource

      public void setDatasource(JKDataSource datasource)
    • setPageRowsCount

      public void setPageRowsCount(int pageRowsCount)
      This method sets the number of rows to be displayed on each page.
      Specified by:
      setPageRowsCount in interface DataPager
      Parameters:
      pageRowsCount - Specifies the new number of rows per page.
    • setQuery

      public void setQuery(String query)
      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.