public abstract class Result extends Object implements AutoCloseable
A Result object maintains a cursor pointing to its current row of data.
Initially the cursor is positioned before the first row. The next()
method moves the cursor to the next row, and because it returns false when
there are no more rows in the Result object, it can be used in a while loop
to iterate through the result set.
The Result interface provides getter methods (getInt(int)
,
getString(int)
, and so on) for retrieving column values from the
current row. Values can be retrieved using either the index number of the
column or the name of the column. In general, using the column index will be
more efficient. Columns are numbered from 0. For maximum portability, result
set columns within each row should be read in left-to-right order, and each
column should be read only once. For the getter methods, a driver attempts to
convert the underlying data to the Java type specified in the getter method
and returns a suitable Java value.
Column names used as input to getter methods are case insensitive. When a getter method is called with a column name and several columns have the same name, the value of the first matching column will be returned. The column name option is designed to be used when column names are used in the SQL query that generated the result set. For columns that are NOT explicitly named in the query, it is best to use column numbers. If column names are used, the programmer should take care to guarantee that they uniquely refer to the intended columns, which can be assured with the SQL AS clause.
The number, types and properties of a Results object's column are provided by
the ColumnMetaData
object returned by the getMetadata(int)
method.
Constructor and Description |
---|
Result() |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes this
Result and releases all used resources. |
void |
dump()
Prints the contents of this result to
System.out . |
void |
dump(PrintStream out)
Prints the contents of this result to
out . |
boolean |
getBoolean(int col)
Gets the value of the designated column in the current row of this
Result object as an boolean . |
boolean |
getBoolean(int col,
boolean defaultValue)
Gets the value of the designated column in the current row of this
Result object as an boolean . |
boolean |
getBoolean(String colName)
Gets the value of the designated column in the current row of this
Result object as an boolean . |
boolean |
getBoolean(String colName,
boolean defaultValue)
Gets the value of the designated column in the current row of this
Result object as an boolean . |
byte |
getByte(int col)
Gets the value of the designated column in the current row of this
Result object as an byte . |
byte |
getByte(int col,
byte defaultValue)
Gets the value of the designated column in the current row of this
Result object as an byte . |
byte |
getByte(String colName)
Gets the value of the designated column in the current row of this
Result object as an byte . |
byte |
getByte(String colName,
byte defaultValue)
Gets the value of the designated column in the current row of this
Result object as an byte . |
abstract int |
getColumnCount()
Returns the number of columns.
|
int |
getColumnIndex(String colName)
Returns the index of the column with the specified name.
|
DBDataSource |
getDataSource()
Gets the
DBDataSource of this Result . |
double |
getDouble(int col)
Gets the value of the designated column in the current row of this
Result object as an double . |
double |
getDouble(int col,
double defaultValue)
Gets the value of the designated column in the current row of this
Result object as an double . |
double |
getDouble(String colName)
Gets the value of the designated column in the current row of this
Result object as an double . |
double |
getDouble(String colName,
double defaultValue)
Gets the value of the designated column in the current row of this
Result object as an double . |
float |
getFloat(int col)
Gets the value of the designated column in the current row of this
Result object as an float . |
float |
getFloat(int col,
float defaultValue)
Gets the value of the designated column in the current row of this
Result object as an float . |
float |
getFloat(String colName)
Gets the value of the designated column in the current row of this
Result object as an float . |
float |
getFloat(String colName,
float defaultValue)
Gets the value of the designated column in the current row of this
Result object as an float . |
int |
getInt(int col)
Gets the value of the designated column in the current row of this
Result object as an int . |
int |
getInt(int col,
int defaultValue)
Gets the value of the designated column in the current row of this
Result object as an int . |
int |
getInt(String colName)
Gets the value of the designated column in the current row of this
Result object as an int . |
int |
getInt(String colName,
int defaultValue)
Gets the value of the designated column in the current row of this
Result object as an int . |
long |
getLong(int col)
Gets the value of the designated column in the current row of this
Result object as an long . |
long |
getLong(int col,
long defaultValue)
Gets the value of the designated column in the current row of this
Result object as an long . |
long |
getLong(String colName)
Gets the value of the designated column in the current row of this
Result object as an long . |
long |
getLong(String colName,
long defaultValue)
Gets the value of the designated column in the current row of this
Result object as an long . |
Integer |
getMaxRowCount()
Returns the
maxRowCount for this Result . |
abstract ColumnMetaData |
getMetadata(int col)
Returns the cached
ColumnMetadata for the column with index
col . |
abstract Object |
getObject(int col)
Gets the value of the designated column in the current row of this
Result object as an Object . |
Object |
getObject(String colName)
Gets the value of the designated column in the current row of this
Result object as an Object . |
QueryInfo |
getQueryInfo()
|
short |
getShort(int col)
Gets the value of the designated column in the current row of this
Result object as an short . |
short |
getShort(int col,
short defaultValue)
Gets the value of the designated column in the current row of this
Result object as an short . |
short |
getShort(String colName)
Gets the value of the designated column in the current row of this
Result object as an short . |
short |
getShort(String colName,
short defaultValue)
Gets the value of the designated column in the current row of this
Result object as an short . |
String |
getString(int col)
Gets the value of the designated column in the current row of this
Result object as an String . |
String |
getString(int col,
String defaultValue)
Gets the value of the designated column in the current row of this
Result object as an String . |
String |
getString(String colName)
Gets the value of the designated column in the current row of this
Result object as an String . |
String |
getString(String colName,
String defaultValue)
Gets the value of the designated column in the current row of this
Result object as an String . |
abstract boolean |
next() |
void |
setDataSource(DBDataSource dataSource)
Sets the
dataSource for this Result . |
void |
setMaxRowCount(Integer maxRowCount)
Sets the maxRowCount for this
Result instance,
null means not specified. |
void |
setQueryInfo(QueryInfo queryInfo)
Sets the
queryInfo for this Result . |
abstract int |
skip(int count)
Skips over the specified count of rows.
|
public void setDataSource(DBDataSource dataSource)
dataSource
for this Result
.dataSource
- the DBDataSource
of this Result
public DBDataSource getDataSource()
DBDataSource
of this Result
.DBDataSource
of this Result
public void setMaxRowCount(Integer maxRowCount)
Result
instance,
null
means not specified.maxRowCount
- public Integer getMaxRowCount()
maxRowCount
for this Result
.Result
instance or
null if none has been specified.public abstract int getColumnCount()
int
value.public abstract ColumnMetaData getMetadata(int col)
ColumnMetadata
for the column with index
col
.
Note that col
starts with 0 for the first column.
col
- the index of the column whose ColumnMetadata
shall be returned, starting at 0ColumnMetadata
of the column with index
col
public abstract boolean next() throws DBException
true
if there is another row to be returned,
otherwise false
.DBException
- if any error occurred.public abstract int skip(int count) throws DBException
The skip method may, for a variety of reasons, end up skipping over some smaller number of rows, possibly 0. This may be caused by reaching the end of the result.
count
- the number of rows to skipDBException
- if any error occuredpublic abstract Object getObject(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an Object
.
col
- the index of the columnjava.lang.Object
holding the column valueDBException
- if the columnIndex is not valid; if a database access error
occurs.public Object getObject(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an Object
.
colName
- the name of the columnjava.lang.Object
holding the column valueDBException
- if the columnIndex is not valid; if a database access error
occurs.public int getColumnIndex(String colName) throws DBException
colName
- as a String
DBException
- if the columnIndex is not valid; if a database access error
occurs.public String getString(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an String
.
col
- the index of the columnString
holding the column valueDBException
- if the columnIndex is not valid; if a database access error
occurs.getString(int, String)
public String getString(int col, String defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an String
.
col
- the index of the columndefaultValue
- the default String
String
holding the column value, if the column value is
null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs.getObject(int)
public String getString(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an String
.
colName
- the name of the columnString
holding the column valueDBException
- if the columnIndex is not valid; if a database access error
occurs.public String getString(String colName, String defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an String
.
colName
- the name of the columndefaultValue
- the default String
String
holding the column value, if the column value is
null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs.getColumnIndex(String)
,
getString(int, String)
public byte getByte(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an byte
.
col
- the index of the columnbyte
holding the column value; If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getByte(int, byte)
public byte getByte(int col, byte defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an byte
.
col
- the index of the columndefaultValue
- the default byte
byte
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public byte getByte(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an byte
.
colName
- the name of the columnbyte
holding the column value; If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getByte(int)
public byte getByte(String colName, byte defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an byte
.
colName
- the name of the columndefaultValue
- the default byte
byte
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getByte(int, byte)
public short getShort(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an short
.
col
- the index of the columnshort
holding the column value; If the column
value is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getShort(int, short)
public short getShort(int col, short defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an short
.
col
- the index of the columndefaultValue
- the default byte
short
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public short getShort(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an short
.
colName
- the name of the columnshort
holding the column value; If the column
value is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getShort(int)
public short getShort(String colName, short defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an short
.
colName
- the name of the columndefaultValue
- the default short
short
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getShort(int, short)
public int getInt(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an int
.
col
- the index of the columnint
holding the column value. If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getInt(int, int)
public int getInt(int col, int defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an int
.
col
- the index of the columndefaultValue
- the default int
int
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public int getInt(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an int
.
colName
- the name of the columnint
holding the column value. If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getInt(int)
public int getInt(String colName, int defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an int
.
colName
- the name of the columndefaultValue
- the default int
int
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getInt(int, int)
public long getLong(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an long
.
col
- the index of the columnlong
holding the column value. If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getLong(int, long)
public long getLong(int col, long defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an long
.
col
- the index of the columndefaultValue
- the default long
long
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public long getLong(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an long
.
colName
- the name of the columnlong
holding the column value. If the column value
is null
, 0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getLong(int)
public long getLong(String colName, long defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an long
.
colName
- the name of the columndefaultValue
- the default long
long
holding the column value, if the column value
is null
the defaultValue
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getLong(int, long)
public float getFloat(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an float
.
col
- the index of the columnfloat
holding the column value. If the column
value is null
, 0f is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getFloat(int, float)
public float getFloat(int col, float defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an float
.
col
- the index of the columndefaultValue
- the default float
float
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public float getFloat(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an float
.
colName
- the name of the columnfloat
holding the column value. If the column
value is null
, 0f is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getFloat(int)
public float getFloat(String colName, float defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an float
.
colName
- the name of the columndefaultValue
- the default float
float
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getFloat(int, float)
public double getDouble(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an double
.
col
- the index of the columndouble
holding the column value. If the column
value is null
, 0.0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getDouble(int, double)
public double getDouble(int col, double defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an double
.
col
- the index of the columndefaultValue
- the default double
double
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public double getDouble(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an double
.
colName
- the name of the columndouble
holding the column value. If the column
value is null
, 0.0 is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.public double getDouble(String colName, double defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an double
.
colName
- the name of the columndefaultValue
- the default double
double
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getDouble(int, double)
public boolean getBoolean(int col) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an boolean
.
col
- the index of the columnboolean
holding the column value. If the column
value is null
, false
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getBoolean(int, boolean)
public boolean getBoolean(int col, boolean defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an boolean
.
col
- the index of the columndefaultValue
- the default boolean
boolean
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getObject(int)
public boolean getBoolean(String colName) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an boolean
.
colName
- the name of the columnboolean
holding the column value. If the column
value is null
, false
is returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getBoolean(int)
public boolean getBoolean(String colName, boolean defaultValue) throws DBException
Gets the value of the designated column in the current row of this
Result
object as an boolean
.
colName
- the name of the columndefaultValue
- the default boolean
boolean
holding the column value, if the column
value is null
the defaultValue
is
returned.DBException
- if the columnIndex is not valid; if a database access error
occurs or the value can not be cast.getColumnIndex(String)
,
getBoolean(int, boolean)
public abstract void close() throws DBException
Result
and releases all used resources.close
in interface AutoCloseable
DBException
- if a database access error occurs.public void dump() throws DBException
System.out
.DBException
public void dump(PrintStream out) throws DBException
out
.out
- the stream to print toDBException
Copyright © 2003–2020 XDEV Software. All rights reserved.