|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlitebase.ResultSet
public class ResultSet
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");
Result sets cannot be constructed directly; instead, you must issue a sql to the driver.
| Constructor Summary | |
|---|---|
ResultSet()
|
|
| Method Summary | |
|---|---|
boolean |
absolute(int row)
Places this result set 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()
Closes a result set. |
boolean |
first()
Places the cursor in the first record of the result set. |
byte[] |
getBlob(int colIdx)
Given the column index (starting from 1), returns a byte (blob) array that is represented by this column. |
byte[] |
getBlob(java.lang.String colName)
Given the column name (case insensitive), returns a byte array (blob) that is represented by this column. |
char[] |
getChars(int colIdx)
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. |
totalcross.util.Date |
getDate(int colIdx)
Given the column index (starting from 1), returns a Date value that is represented by this column. |
totalcross.util.Date |
getDate(java.lang.String colName)
Given the column name (case insensitive), returns a Date value that is represented by this column. |
totalcross.sys.Time |
getDateTime(int colIdx)
Given the column index (starting from 1), returns a Time (correspondent to a DATETIME data type) value that is represented by this
column. |
totalcross.sys.Time |
getDateTime(java.lang.String colName)
Given the column name (case insensitive), returns a Time (correspondent to a DATETIME data type) value that is represented by this
column. |
double |
getDouble(int colIdx)
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. |
double |
getFloat(int colIdx)
Given the column index (starting from 1), returns a float value that is represented by this column. |
double |
getFloat(java.lang.String colName)
Given the column name (case insensitive), returns a float value that is represented by this column. |
int |
getInt(int colIdx)
Given the column index (starting from 1), returns an integer value that is represented by this column. |
int |
getInt(java.lang.String colName)
Given the column name (case insensitive), returns an integer value that is represented by this column. |
long |
getLong(int colIdx)
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 meta data for this result set. |
int |
getRow()
Returns the current physical row of the table where the cursor is. |
int |
getRowCount()
Returns the number of rows of the result set. |
short |
getShort(int colIdx)
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 colIdx)
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()
Starting from the current cursor position, it reads all result set rows of the result set. |
java.lang.String[][] |
getStrings(int count)
Starting from the current cursor position, it reads all result set rows that are being requested. |
boolean |
isNull(int colIdx)
Given the column index (starting from 1), indicates if this column has a NULL. |
boolean |
isNull(java.lang.String colName)
Given the column name (case insensitive), indicates if this column has a NULL. |
boolean |
last()
Places the cursor in the last record of the result set. |
boolean |
next()
Gets the next record of the result set. |
boolean |
prev()
Returns the previous record of the result set. |
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 |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResultSet()
| Method Detail |
|---|
public ResultSetMetaData getResultSetMetaData()
throws DriverException
DriverException - If the result set is closed.public void close()
DriverException - if the result set is closed.
public void beforeFirst()
throws DriverException
DriverException - If the result set is closed.
public void afterLast()
throws DriverException
DriverException - If the result set is closed.
public boolean first()
throws DriverException
true if it was possible to place the cursor in the first record; false, otherwise.
DriverException - If the result set is closed.
public boolean last()
throws DriverException
true if it was possible to place the cursor in the last record; false, otherwise.
DriverException - If the result set is closed.
public boolean next()
throws DriverException
true if there is a next record to go to in the result set; false, otherwise.
DriverException - If the result set is closed or an IOException occurs.
public boolean prev()
throws DriverException
true if there is a previous record to go to in the result set; false, otherwise.
DriverException - If the result set is closed or an IOException occurs.public short getShort(int colIdx)
colIdx - The column index.
NULL, the value returned is 0.public short getShort(java.lang.String colName)
colName - The column name.
NULL, the value returned is 0.public int getInt(int colIdx)
colIdx - The column index.
NULL, the value returned is 0.public int getInt(java.lang.String colName)
colName - The column name.
NULL, the value returned is 0.public long getLong(int colIdx)
colIdx - The column index.
NULL, the value returned is 0.public long getLong(java.lang.String colName)
colName - The column name.
NULL, the value returned is 0.public double getFloat(int colIdx)
colIdx - The column index.
NULL, the value returned is 0.0.public double getFloat(java.lang.String colName)
colName - The column name.
NULL, the value returned is 0.0.public double getDouble(int colIdx)
colIdx - The column index.
NULL, the value returned is 0.0.public double getDouble(java.lang.String colName)
colName - The column name.
NULL, the value returned is 0.0.public char[] getChars(int colIdx)
colIdx - The column index.
NULL, the value returned is null.public char[] getChars(java.lang.String colName)
colName - The column name.
NULL, the value returned is null.public byte[] getBlob(int colIdx)
colIdx - the column index.
NULL, the value returned is null.public byte[] getBlob(java.lang.String colName)
colName - The column name.
NULL, the value returned is null.public java.lang.String getString(int colIdx)
Double/float values formatting will use the precision set with the setDecimalPlaces() method.
colIdx - The column index.
NULL, the value returned is nullpublic java.lang.String getString(java.lang.String colName)
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.
colName - The column name.
NULL, the value returned is null
public java.lang.String[][] getStrings(int count)
throws DriverException
first(), last(),
prev(), or next() must be used to set the current position, but not beforeFirst() or
afterLast(). It doesn't return BLOB values. null is returned in their places instead.
count - The number of rows to be fetched, or -1 for all.
String[0] is the first row, and String[0][0], String[0][1]... are the column elements of the
first row. Returns null if there's no more element to be fetched. Double/float values will be formatted using
setDecimalPlaces() settings. If the value is SQL NULL, the value returned is null.
- Throws:
DriverException - If the result set is closed or an IOException occurs.
SQLParseException - If an InvalidDateException occurs.public java.lang.String[][] getStrings()
first(), last(),
prev(), or next() must be used to set the current position, but not beforeFirst() or
afterLast(). It doesn't return BLOB values. null is returned in their places instead.
String[0] is the first row, and String[0][0], String[0][1]... are the column elements of the
first row. Returns null if there's no more element to be fetched. Double/float values will be formatted using the
setDecimalPlaces() settings. If the value is SQL NULL, the value returned is null.
public totalcross.util.Date getDate(int colIdx)
throws SQLParseException
Date value that is represented by this column. Note that it is only possible
to request this column as a date if it was created this way (DATE).
colIdx - The column index.
Date object; if the value is SQL NULL, the value returned is null.
SQLParseException - If an InvalidDateException occurs.
public totalcross.util.Date getDate(java.lang.String colName)
throws DriverException
Date value that is represented by this column. Note that it is only possible
to request this column as a date if it was created this way (DATE). This method is slightly slower then the method that accepts a column index.
colName - The column name.
Date object; if the value is SQL NULL, the value returned is null.
SQLParseException - If an InvalidDateException occurs.
DriverExceptionpublic totalcross.sys.Time getDateTime(int colIdx)
Time (correspondent to a DATETIME data type) value that is represented by this
column. Note that it is only possible to request this column as a datetime if it was created this way.
colIdx - The colum index, starting from 1.
Time object; if the DATETIME value is SQL NULL, the value returned is
null.public totalcross.sys.Time getDateTime(java.lang.String colName)
Time (correspondent to a DATETIME data type) value that is represented by this
column. Note that it is only possible to request this column as a datetime if it was created this way. This method is slightly slower then the
method that accepts a column index.
colName - The colum name.
Time object; if the DATETIME value is SQL NULL, the value returned is
null.
public boolean absolute(int row)
throws DriverException
getRow() method.
row - The row to set the cursor.
true whenever this method does not throw an exception.
DriverException - the result set is closed or an IOException occurs.
public boolean relative(int rows)
throws DriverException
rows in distance. The value can be greater or lower than zero.
rows - The distance to move the cursor.
true whenever this method does not throw an exception.
DriverException - If the result set is closed or an IOException occurs.
public int getRow()
throws DriverException
absolute() method.
DriverException - If the result set is closed.
public void setDecimalPlaces(int col,
int places)
throws DriverException
String.
col - The column.places - The number of decimal places.
DriverException - If the result set is closed, the column index is invalid, or the value for decimal places is invalid.
public int getRowCount()
throws DriverException
DriverException - If the result set is closed.
public boolean isNull(int colIdx)
throws DriverException
NULL.
colIdx - The column index.
true if the value is SQL NULL; false, otherwise.
DriverException - If the result set is closed.
public boolean isNull(java.lang.String colName)
throws DriverException
NULL.
colName - The column name.
true if the value is SQL NULL; false, otherwise.
DriverException - If the result set is closed or the column name is not found.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||