SqlResultSet

Framework Components [com.onepg.db]

← Back to Class List

Class Information

Package: com.onepg.db

Class Name: SqlResultSet

Description

SQL result set wrapper class.
  • A wrapper class for the result set ResultSet that provides an iterator and handles closing of the statement and result set.
  • By using this class, data can only be retrieved through the iterator.
  • Declare in a try clause (try-with-resources statement).
  • The physical field names in the row map retrieved from the iterator of this class are in lowercase English letters. (IoItems keys)

Method List

iterator

public Iterator<IoItems> iterator()
Creates an iterator.

Return Value

Iterator<IoItems> - the result row iterator

close

public void close()
Closes the result set and statement.
  • Closes the result set and statement.

isExists

public boolean isExists()
Checks if data exists (matches database retrieval conditions).
  • In DB2, #isBeforeFirst (with TYPE_FORWARD_ONLY) causes an error.

Return Value

boolean - true if data was retrieved

getReadedCount

public int getReadedCount()
Retrieves the number of rows read (not the count matching database retrieval conditions).
  • Returns the count read by the iterator.

Return Value

int - the number of rows read

isReadedEndRow

public boolean isReadedEndRow()
Determines if the last row has been read.

Return Value

boolean - true if the last row has been read

getItemNames

public String[] getItemNames()
Retrieves database column names.

Return Value

String[] - the database column name string array

hasNext

public boolean hasNext()
Checks if the next row exists.
  • Closes the result set and statement if the next row does not exist, in case the try clause was not used.
  • Does not recheck on consecutive hasNext() calls.

Return Value

boolean - true if the next row exists