sqlwrapper
Class QueryResult

java.lang.Object
  extended by sqlwrapper.QueryResult
All Implemented Interfaces:
java.util.Iterator

public class QueryResult
extends java.lang.Object
implements java.util.Iterator

Implementation of the query ResultSet that supports pageable query for handling large data sets that does not fit into the memory.


Field Summary
private  java.sql.ResultSet currentPage
           
private  int currentPageInd
           
private  java.util.ArrayList currentRecord
           
private  int currentRecordInd
           
private  int numberOfPages
           
private  int numCols
           
private  boolean pageLoaded
           
private  int pageSize
           
private  java.lang.String query
           
private  int recordCount
           
private  java.sql.Statement stat
           
 
Constructor Summary
QueryResult(java.sql.Statement stat, java.lang.String sql)
          Class constructor
 
Method Summary
 boolean hasNext()
          Returns false if resutSet pointer reaches the end of the set, returns true otherwise.
 java.lang.Object next()
          Extract the next data from the resultSet.
 void nextPage()
          Next page is retrieved from disk to memory
 void remove()
           
 void setPageSize(int pageSize)
          Set the maximum number of tuples that resides in a page
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

private java.lang.String query

stat

private java.sql.Statement stat

currentRecordInd

private int currentRecordInd

currentPageInd

private int currentPageInd

currentRecord

private java.util.ArrayList currentRecord

recordCount

private int recordCount

numCols

private int numCols

pageSize

private int pageSize

numberOfPages

private int numberOfPages

pageLoaded

private boolean pageLoaded

currentPage

private java.sql.ResultSet currentPage
Constructor Detail

QueryResult

public QueryResult(java.sql.Statement stat,
                   java.lang.String sql)
            throws java.sql.SQLException
Class constructor

Parameters:
stat - Statement object for executing sql query
sql - SQL query
Throws:
java.sql.SQLException
Method Detail

hasNext

public boolean hasNext()
Returns false if resutSet pointer reaches the end of the set, returns true otherwise.

Specified by:
hasNext in interface java.util.Iterator
Returns:
success

next

public java.lang.Object next()
Extract the next data from the resultSet. If the end of the currentPage is reached, next page is retrieved from disk to memory.

Specified by:
next in interface java.util.Iterator
Returns:
next tuple from the resultSet

nextPage

public void nextPage()
              throws java.sql.SQLException
Next page is retrieved from disk to memory

Throws:
java.sql.SQLException

setPageSize

public void setPageSize(int pageSize)
Set the maximum number of tuples that resides in a page

Parameters:
pageSize - number of tuples

remove

public void remove()
Specified by:
remove in interface java.util.Iterator