litebase
Class ResultSet

java.lang.Object
  |
  +--litebase.ResultSet

public final class ResultSet
extends java.lang.Object

This class represents a set or rows resulting from a LitebaseConnection.executeQuery method call. Here's an example:

    ResultSet rs = driver.executeQuery("select name, salary, age from person");
    while (rs.next())
       Vm.debug(pad(rs.getString("name"),32) + pad(rs.getString("salary"),16) + rs.getInt("age")+" years");
 


Field Summary
protected  java.lang.Object bag
           
 
Method Summary
 boolean absolute(int row)
          Places this RecordSet cursor at the given absolute row.
 void afterLast()
          Places the cursor after the last record
 void beforeFirst()
          Places the cursor before the first record
 void close()
          Releases all memory allocated for this object.
 boolean first()
          Places the cursor in the first record
 char[] getChars(int col)
          Given the column index (starting from 1), returns a char array that is represented by this column.
 char[] getChars(java.lang.String colName)
          Given the column name (case insensitive), returns a char array that is represented by this column.
 waba.util.Date getDate(int col)
          Given the column index (starting from 1), returns a Date value that is represented by this column.
 waba.util.Date getDate(java.lang.String colName)
          Given the column name (case insensitive), returns an Date value that is represented by this column.
 waba.sys.Time getDateTime(int col)
          Given the column index (starting from 1), returns a Time (correspondent to DATETIME LitebaseConnection data type) value that is represented by this column.
 waba.sys.Time getDateTime(java.lang.String colName)
          Given the column name (case insensitive), returns a Time (correspondent to DATETIME LitebaseConnection data type) value that is represented by this column.
 double getDouble(int col)
          Given the column index (starting from 1), returns a double value that is represented by this column.
 double getDouble(java.lang.String colName)
          Given the column name (case insensitive), returns a double value that is represented by this column.
 float getFloat(int col)
          Given the column index (starting from 1), returns a float value that is represented by this column.
 float getFloat(java.lang.String colName)
          Given the column name (case insensitive), returns a float value that is represented by this column.
 int getInt(int col)
          Given the column index (starting from 1), returns an int value that is represented by this column.
 int getInt(java.lang.String colName)
          Given the column name (case insensitive), returns an int value that is represented by this column.
 long getLong(int col)
          Given the column index (starting from 1), returns a long value that is represented by this column.
 long getLong(java.lang.String colName)
          Given the column name (case insensitive), returns a long value that is represented by this column.
 ResultSetMetaData getResultSetMetaData()
          Returns the metadata for this resultset.
 int getRow()
          Returns the current physical row of the Table that the cursor is.
 int getRowCount()
          Returns the number of rows of this resultset
 short getShort(int col)
          Given the column index (starting from 1), returns a short value that is represented by this column.
 short getShort(java.lang.String colName)
          Given the column name (case insensitive), returns a short value that is represented by this column.
 java.lang.String getString(int col)
          Given the column index (starting from 1), returns a String that is represented by this column.
 java.lang.String getString(java.lang.String colName)
          Given the column name (case insensitive), returns a String that is represented by this column.
 java.lang.String[][] getStrings()
          Returns all Strings of this resultset in order, starting from the first record.
 java.lang.String[][] getStrings(int count)
          This is the most powerful method of this class.
 java.lang.String[][] getStrings(int count, boolean forward, boolean invert)
          Deprecated. Use getStrings(count) instead.
 boolean last()
          Places the cursor in the last record
 boolean next()
          Returns the next record of this ResultSet
 boolean prev()
          Returns the previous record of this ResultSet
 boolean relative(int rows)
          Moves the cursor rows in distance.
 void setDecimalPlaces(int col, int places)
          Sets the number of decimal places that the given column (starting from 1) will have when being converted to String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bag

protected java.lang.Object bag
Method Detail

getResultSetMetaData

public ResultSetMetaData getResultSetMetaData()
Returns the metadata for this resultset.

close

public void close()
Releases all memory allocated for this object. Its a good idea to call this when you no longer needs it, but it is also called by the GC when the object is no longer in use.

beforeFirst

public void beforeFirst()
Places the cursor before the first record

afterLast

public void afterLast()
Places the cursor after the last record

first

public boolean first()
Places the cursor in the first record

last

public boolean last()
Places the cursor in the last record

next

public boolean next()
Returns the next record of this ResultSet

prev

public boolean prev()
Returns the previous record of this ResultSet

getShort

public short getShort(int col)
Given the column index (starting from 1), returns a short value that is represented by this column. Note that you must only request this column as short if it was created with this precision.

getShort

public short getShort(java.lang.String colName)
Given the column name (case insensitive), returns a short value that is represented by this column. Note that you must only request this column as short if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getInt

public int getInt(int col)
Given the column index (starting from 1), returns an int value that is represented by this column. Note that you must only request this column as int if it was created with this precision.

getInt

public int getInt(java.lang.String colName)
Given the column name (case insensitive), returns an int value that is represented by this column. Note that you must only request this column as int if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getLong

public long getLong(int col)
Given the column index (starting from 1), returns a long value that is represented by this column. Note that you must only request this column as long if it was created with this precision.

getLong

public long getLong(java.lang.String colName)
Given the column name (case insensitive), returns a long value that is represented by this column. Note that you must only request this column as long if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getFloat

public float getFloat(int col)
Given the column index (starting from 1), returns a float value that is represented by this column. Note that you must only request this column as float if it was created with this precision.

getFloat

public float getFloat(java.lang.String colName)
Given the column name (case insensitive), returns a float value that is represented by this column. Note that you must only request this column as float if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getDouble

public double getDouble(int col)
Given the column index (starting from 1), returns a double value that is represented by this column. Note that you must only request this column as double if it was created with this precision.

getDouble

public double getDouble(java.lang.String colName)
Given the column name (case insensitive), returns a double value that is represented by this column. Note that you must only request this column as double if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getChars

public char[] getChars(int col)
Given the column index (starting from 1), returns a char array that is represented by this column. Note that you must only request this column as char[] if it was created as an array of chars.

getChars

public char[] getChars(java.lang.String colName)
Given the column name (case insensitive), returns a char array that is represented by this column. Note that you must only request this column as char[] if it was created as an array of chars. This method is slightly slower then the method that accepts a column index.

getString

public java.lang.String getString(int col)
Given the column index (starting from 1), returns a String that is represented by this column. Any column type can be returned as String. Double/float values formatting will use the precision set with the setDecimalPlaces method.

getString

public java.lang.String getString(java.lang.String colName)
Given the column name (case insensitive), returns a String that is represented by this column. Any column type can be returned as String. Double/float values formatting will use the precision set with the setDecimalPlaces method. This method is slightly slower then the method that accepts a column index.

getStrings

public java.lang.String[][] getStrings(int count,
                                       boolean forward,
                                       boolean invert)
Deprecated. Use getStrings(count) instead.

This is the most powerful method of this class. Starting from the current cursor position (must use first,last,prev or next, not beforeFirst or afterLast), it reads all ResultSet rows that's being requested.
Parameters:
count - the number of rows to be fetched, or -1 for all. IMPORTANT: The total number of rows being fetched cannot be greater than 16300 due to stack limits.
forward - determines the direction where the rows will be fetched.
invert - determines if the returning array will be inverted or not.
See Also:
getStrings(int)

getStrings

public java.lang.String[][] getStrings(int count)
This is the most powerful method of this class. Starting from the current cursor position (must use first, last, prev or next, not beforeFirst or afterLast), it reads all ResultSet rows that's being requested.
Parameters:
count - the number of rows to be fetched, or -1 for all. IMPORTANT: The total number of rows being fetched cannot be greater than 16300 due to stack limits.

getStrings

public java.lang.String[][] getStrings()
Returns all Strings of this resultset in order, starting from the first record.
See Also:
IMPORTANT: The total number of rows being fetched cannot be greater than 16300 due to stack limits.

getDate

public waba.util.Date getDate(java.lang.String colName)
Given the column name (case insensitive), returns an Date value that is represented by this column. Note that you must only request this column as Date if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getDate

public waba.util.Date getDate(int col)
Given the column index (starting from 1), returns a Date value that is represented by this column. Note that you must only request this column as Date if it was created with this precision.

getDateTime

public waba.sys.Time getDateTime(java.lang.String colName)
Given the column name (case insensitive), returns a Time (correspondent to DATETIME LitebaseConnection data type) value that is represented by this column. Note that you must only request this column as DateTime if it was created with this precision. This method is slightly slower then the method that accepts a column index.

getDateTime

public waba.sys.Time getDateTime(int col)
Given the column index (starting from 1), returns a Time (correspondent to DATETIME LitebaseConnection data type) value that is represented by this column. Note that you must only request this column as DateTime if it was created with this precision.

absolute

public boolean absolute(int row)
Places this RecordSet cursor at the given absolute row. This is the absolute physical row of the table. You usually use this method to restore the row at a previous row got with the getRow method.

relative

public boolean relative(int rows)
Moves the cursor rows in distance. Returns false if it can't move in that direction, true if it moved at least 1 row in the direction. Can be greater or lower than zero. Note that you cannot use this method right after you do a select; you must call first or last before.

getRow

public int getRow()
Returns the current physical row of the Table that the cursor is. Must be used with absolute method.

setDecimalPlaces

public void setDecimalPlaces(int col,
                             int places)
Sets the number of decimal places that the given column (starting from 1) will have when being converted to String. Must be used for columns of type DOUBLE or FLOAT only.

getRowCount

public int getRowCount()
Returns the number of rows of this resultset