|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectorg.apache.commons.dbutils.QueryRunner
ResultSet をハンドルするプラグ化可能なストラテジーを持つ SQL の問い合わせを実行します。
このクラスはスレッドセーフです。
ResultSets. This class is thread safe.
ResultSetHandler | フィールドの概要 | |
protected DataSource |
ds
接続を取り出すためのデータソース。 |
| コンストラクタの概要 | |
QueryRunner()
QueryRunner のコンストラクタ。 |
|
QueryRunner(DataSource ds)
QueryRunnerのコンストラクタ。 |
|
| メソッドの概要 | |
protected void |
fillStatement(PreparedStatement stmt,
Object[] params)
PreparedStatement の置換パラメータに、 指定したオブジェクトを埋め込みます。
|
DataSource |
getDataSource()
このRunnerが使用している DataSource を返します。
|
protected PreparedStatement |
prepareStatement(Connection conn,
String sql)
指定したSQLに対応する PreparedStatement オブジェクトを作成および初期化します。
|
Object |
query(Connection conn,
String sql,
Object[] params,
ResultSetHandler rsh)
置換パラメータを埋め込んだ SQL SELECT の問い合わせを実行します。 |
Object |
query(Connection conn,
String sql,
Object param,
ResultSetHandler rsh)
単一の置換パラメータを埋め込んだ SQL SELECT の問い合わせを実行します。 |
Object |
query(Connection conn,
String sql,
ResultSetHandler rsh)
置換パラメータが一切含まれない SQL SELECT の問い合わせを実行します。 |
Object |
query(String sql,
Object[] params,
ResultSetHandler rsh)
指定された SQL SELECT を実行し、結果を格納したオブジェクトを返します。 |
Object |
query(String sql,
Object param,
ResultSetHandler rsh)
単一の置換パラメータを含む、指定された SQL SELECT を実行します。 |
Object |
query(String sql,
ResultSetHandler rsh)
指定された SQL SELECT を置換パラメータなしで実行します。 |
protected void |
rethrow(SQLException cause,
String sql,
Object[] params)
さらに有益なエラーメッセージを含む新規の例外をスローします Throws a new exception with a more informative error message. |
void |
setDataSource(DataSource dataSource)
この Runner がデータベース接続を取得するのに使用する DataSource をセットします。
|
int |
update(Connection conn,
String sql)
置換パラメータのない SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
int |
update(Connection conn,
String sql,
Object param)
単一の置換パラメータを埋め込んだ SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
int |
update(Connection conn,
String sql,
Object[] params)
SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
int |
update(String sql)
置換パラメータを含まない、指定された SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
int |
update(String sql,
Object param)
単一の置換パラメータを含む、指定された SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
int |
update(String sql,
Object[] params)
指定された SQL INSERT、UPDATE、または、DELETE の問い合わせを実行します。 |
protected ResultSet |
wrap(ResultSet rs)
ResultSet を処理する前に、デコレータによってラップします。
|
| クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| フィールドの詳細 |
protected DataSource ds
| コンストラクタの詳細 |
public QueryRunner()
public QueryRunner(DataSource ds)
Connection パラメータを使用しないメソッドでは、 この
DataSource から接続を取り出します。
Connection parameter will retrieve connections from this
DataSource.
ds - 接続を取り出すためのデータソース。
DataSource to retrieve connections from.| メソッドの詳細 |
protected void fillStatement(PreparedStatement stmt,
Object[] params)
throws SQLException
PreparedStatement の置換パラメータに、 指定したオブジェクトを埋め込みます。
PreparedStatement replacement parameters with
the given objects.
stmt - params - 問い合わせの置換パラメータ。 null は有効な値として通過されます。
null is a valid
value to pass in.SQLExceptionpublic DataSource getDataSource()
DataSource を返します。
DataSource this runner is using.
protected PreparedStatement prepareStatement(Connection conn,
String sql)
throws SQLException
PreparedStatement オブジェクトを作成および初期化します。
QueryRunner のメソッドはステートメントを準備するのにこのメソッドを常に呼び出します。
必要であれば、PreparedStatement の特別なコンフィグレーションを提供するためにこのメソッドをサブクラスでオーバーライド可能です。
この実装は、ただ単純に conn.prepareStatement(sql) を呼び出します。
PreparedStatement object for the given SQL.
QueryRunner methods always call this method to prepare
statements for them. Subclasses can override this method to provide
special PreparedStatement configuration if needed. This implementation
simply calls conn.prepareStatement(sql).
conn - PreparedStatement を作成するために使用する Connection。
Connection used to create the
PreparedStatementsql - 準備対象の SQL ステートメント。
PreparedStatement。
PreparedStatement.SQLException
public Object query(Connection conn,
String sql,
Object param,
ResultSetHandler rsh)
throws SQLException
conn - 問い合わせを実行する接続。
sql - 実行する問い合わせ。
param - 置換パラメータ。
rsh - 結果をオブジェクトに変換するハンドラ。
SQLException
public Object query(Connection conn,
String sql,
Object[] params,
ResultSetHandler rsh)
throws SQLException
conn - 問い合わせを実行する接続。
sql - 実行する問い合わせ。
params - 置換パラメータ。
rsh - 結果をオブジェクトに変換するハンドラ。
SQLException
public Object query(Connection conn,
String sql,
ResultSetHandler rsh)
throws SQLException
conn - 問い合わせを実行する接続。
sql - 実行する問い合わせ。
rsh - 結果をオブジェクトに変換するハンドラ。
SQLException
public Object query(String sql,
Object param,
ResultSetHandler rsh)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is retrieved from the
DataSource set in the constructor.
sql - 実行するSQLステートメント。
param - 置換パラメータ。
rsh - ResultSet から結果を格納したオブジェクトを作成するために使用されるハンドラ。
ResultSet.SQLException
public Object query(String sql,
Object[] params,
ResultSetHandler rsh)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is retrieved from the
DataSource set in the constructor.
sql - 実行するSQLステートメント。
params - この配列とともにPreparedStatementのINパラメータを初期化します。
rsh - ResultSet から結果を格納したオブジェクトを作成するために使用されるハンドラ。
ResultSet.SQLException
public Object query(String sql,
ResultSetHandler rsh)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is retrieved from the
DataSource set in the constructor.
sql - 実行するSQLステートメント。
rsh - ResultSet から結果を格納したオブジェクトを作成するために使用されるハンドラ。
ResultSet.SQLException
protected void rethrow(SQLException cause,
String sql,
Object[] params)
throws SQLException
cause - 再スローされる際に、新規の例外へチェーンされる根本的な例外。
sql - 例外発生時に実行した問い合わせ。
params - 問い合わせの置換パラメータ。 null は有効な値として通過されます。
null is a
valid value to pass in.SQLExceptionpublic void setDataSource(DataSource dataSource)
DataSource をセットします。
Connection を渡さない状態で、実行メソッドを使用するつもりであれば、 デフォルトコンストラクタを含め
Runner が作成した後、これを呼び出すようにすべきです。
DataSource this runner will use to get
database connections from. This should be called after creating a
runner with the default constructor if you intend to use the
execute methods without passing in a Connection.
dataSource - 使用するデータソース。
public int update(Connection conn,
String sql)
throws SQLException
conn - 問い合わせを実行するのに使用する接続。
sql - 実行するSQL。
SQLException
public int update(Connection conn,
String sql,
Object param)
throws SQLException
conn - 問い合わせを実行するのに使用する接続。
sql - 実行するSQL。
param - 置換パラメータ。
SQLException
public int update(Connection conn,
String sql,
Object[] params)
throws SQLException
conn - 問い合わせを実行するのに使用する接続。
sql - 実行するSQL。
params - 置換パラメータ。
SQLException
public int update(String sql)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is retrieved
from the DataSource set in the constructor.
sql - 実行するSQL文。
SQLException
public int update(String sql,
Object param)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is
retrieved from the DataSource set in the constructor.
sql - 実行するSQL文。
param - 置換パラメータ。
SQLException
public int update(String sql,
Object[] params)
throws SQLException
Connection は、コンストラクタでセットされた DataSource から取り出されます。
Connection is retrieved from the DataSource
set in the constructor.
sql - 実行するSQL文。
params - PreparedStatement の IN (例. '?')パラメータを初期化します。
SQLExceptionprotected ResultSet wrap(ResultSet rs)
ResultSet を処理する前に、デコレータによってラップします。
この実装は、デコレーションが施された状態でない限り、与えられた ResultSet を返します。
ResultSet in a decorator before processing it.
This implementation returns the ResultSet it is given
without any decoration.多くの場合、このメソッドの実装はこのように無名インナークラスの中でラップされます。
QueryRunner run = new QueryRunner() {
protected ResultSet wrap(ResultSet rs) {
return StringTrimmedResultSet.wrap(rs);
}
};
rs - デコレーションを施す ResultSet。 null ではいけません。
ResultSet to decorate; never null.ResultSet。
ResultSet wrapped in some decorator.
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||