public class ResultSetIterator extends java.lang.Object implements java.lang.Iterable<SqlRow>
ResultSetのWrapperクラス。SqlRowで取得するインタフェースを提供する。
以下に例を示す。
ResultSetIterator rs = statement.executeQuery();
// for-each文を使って、1レコード文のデータを取得する。
for (SqlRow row : rs) {
// SqlRowから各カラムの値を取得し必要な処理を行う。
}
ResultSet| コンストラクタと説明 |
|---|
ResultSetIterator(java.sql.ResultSet rs,
ResultSetConvertor convertor)
パラメータで指定された
ResultSetを保持するResultSetIteratorオブジェクトを生成する。 |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
void |
close()
ResultSet.close()を行う。 |
java.math.BigDecimal |
getBigDecimal(int columnIndex)
カレント行の指定されたカラムの値を
BigDecimalで取得する。 |
java.sql.Blob |
getBlob(int columnIndex)
カレント行の指定されたカラムの値を
Blobで取得する。 |
byte[] |
getBytes(int columnIndex)
カレント行の指定されたカラムの値をbyte配列で取得する。
|
java.util.Date |
getDate(int columnIndex)
カレント行の指定されたカラムの値を
Dateで取得する。 |
java.lang.Integer |
getInteger(int columnIndex)
カレント行の指定されたカラムの値を
Integerで取得する。 |
java.lang.Long |
getLong(int columnIndex)
カレント行の指定されたカラムの値を
Longで取得する。 |
java.sql.ResultSetMetaData |
getMetaData()
ResultSetMetaDataを取得する。 |
java.lang.Object |
getObject(int columnIndex)
カレント行の指定されたカラムの値を
Objectで取得する。 |
SqlRow |
getRow()
現在レコードのデータを取得する。
|
java.lang.Short |
getShort(int columnIndex)
カレント行の指定されたカラムの値を
Shortで取得する。 |
SqlStatement |
getStatement()
Statementを取得する。
|
java.lang.String |
getString(int columnIndex)
カレント行の指定されたカラムの値を
Stringで取得する。 |
java.sql.Timestamp |
getTimestamp(int columnIndex)
カレント行の指定されたカラムの値を
Timestampで取得する。 |
java.util.Iterator<SqlRow> |
iterator()
型Tの要素セットの反復子を返す。
|
boolean |
next()
ResultSet.next() を行う。 |
void |
setStatement(SqlStatement statement)
自身を生成した
SqlStatementを設定する。 |
public ResultSetIterator(java.sql.ResultSet rs,
ResultSetConvertor convertor)
ResultSetを保持するResultSetIteratorオブジェクトを生成する。rs - ResultSetconvertor - ResultSetConvertorpublic void setStatement(SqlStatement statement)
SqlStatementを設定する。statement - ステートメントpublic SqlStatement getStatement()
@Published public boolean next()
ResultSet.next() を行う。true、存在しない場合はfalseDbAccessException - SQLExceptionが発生した場合@Published public java.lang.Object getObject(int columnIndex)
Objectで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getObject(int)@Published public java.lang.String getString(int columnIndex)
Stringで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getString(int)@Published public java.lang.Integer getInteger(int columnIndex)
Integerで取得する。
ResultSet.getInt(int)は、カラムの値がnullの場合は0を返すが、
本メソッドではカラムの値がnullの場合はnullを返す。
カラムの値がIntegerに変換可能な場合は、Integerに変換し返却する。columnIndex - カラムインデックスjava.lang.NumberFormatException - カラムの値をIntegerに変換できなかった場合getObject(int)@Published public java.lang.Long getLong(int columnIndex)
Longで取得する。
ResultSet.getLong(int)は、カラムの値がnullの場合は0を返すが、
本メソッドではカラムの値がnullの場合はnullを返す。
カラムの値がLongに変換可能な場合は、Longに変換し返却する。columnIndex - カラムインデックスjava.lang.NumberFormatException - カラムの値をLongに変換できなかった場合getObject(int)@Published public java.lang.Short getShort(int columnIndex)
Shortで取得する。
ResultSet.getShort(int)は、カラムの値がnullの場合は0を返すが、
本メソッドではカラムの値がnullの場合はnullを返す。
カラムの値がShortに変換可能な場合は、Shortに変換し返却する。columnIndex - カラムインデックスjava.lang.NumberFormatException - カラムの値をShortに変換できなかった場合getObject(int)@Published public java.math.BigDecimal getBigDecimal(int columnIndex)
BigDecimalで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getBigDecimal(int)@Published public java.util.Date getDate(int columnIndex)
Dateで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getDate(int)@Published public java.sql.Timestamp getTimestamp(int columnIndex)
Timestampで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getTimestamp(int)@Published public byte[] getBytes(int columnIndex)
columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getBytes(int)@Published public java.sql.Blob getBlob(int columnIndex)
Blobで取得する。columnIndex - カラムインデックスDbAccessException - SQLExceptionが発生した場合ResultSet.getBlob(int)@Published public SqlRow getRow()
SqlRowを生成する。DbAccessException - SQLExceptionが発生した場合public void close()
ResultSet.close()を行う。DbAccessException - SQLExceptionが発生した場合ResultSet.close()public java.sql.ResultSetMetaData getMetaData()
ResultSetMetaDataを取得する。@Published public java.util.Iterator<SqlRow> iterator()
iterator インタフェース内 java.lang.Iterable<SqlRow>java.lang.IllegalArgumentException - 複数のメソッドから呼び出された場合