public final class DBUtil extends Object
データベース関連の便利なメソッドを集めた簡易ユーティリティークラスです。 全てのメソッドは、static メソッドになっています。
2.1.1.1 (2002/11/15) Serializable インターフェースを削除する。 |
4.0.0.0 (2007/10/16) DBアクセス関係のメソッドのみをパッケージ移動(hayabusa/db ⇒ fukurou/db) |
6.0.4.0 (2014/11/28) ResultSetValue クラスで、ResultSet から値を取得する処理を移植 |
修飾子とタイプ | メソッドと説明 |
---|---|
static String[] |
dbCallExecute(String stmt,
String[] args,
ApplicationInfo appInfo)
初期データベースに接続して、CallableStatement(PL/SQL)を実行します(互換性確保のため残しています)。
|
static String[] |
dbCallExecute(String stmt,
String[] args,
ApplicationInfo appInfo,
String dbid)
検索するデータベースを指定して、CallableStatement(PL/SQL)を実行します(互換性確保のため残しています)。
|
static String[] |
dbCallExecute(String stmt,
String[] args,
Transaction tran)
初期データベースに接続して、CallableStatement(PL/SQL)を実行します(Transaction 対応)。
|
static String[] |
dbCallExecute(String stmt,
String[] args,
Transaction tran,
String dbid)
検索するデータベースを指定して、CallableStatement(PL/SQL)を実行します(Transaction 対応)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
ApplicationInfo appInfo)
初期データベースに接続して、Queryを実行します(互換性確保のため残しています)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
ApplicationInfo appInfo,
String dbid)
検索するデータベースを指定して、Queryを実行します(互換性確保のため残しています)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
ApplicationInfo appInfo,
String dbid,
boolean useHeader)
検索するデータベースを指定して、Queryを実行します(互換性確保のため残しています)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
Transaction tran)
初期データベースに接続して、Queryを実行します(Transaction 対応)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
Transaction tran,
String dbid)
検索するデータベースを指定して、Queryを実行します(Transaction 対応)。
|
static String[][] |
dbExecute(String stmt,
String[] args,
Transaction tran,
String dbid,
boolean useHeader)
検索するデータベースを指定して、Queryを実行します(Transaction 対応)。
|
static int |
dbExist(String stmt,
String[] args,
ApplicationInfo appInfo,
String dbid)
SQL文の実行結果において、データの件数を取得します(互換性確保のため残しています)。
|
static int |
dbExist(String stmt,
String[] args,
Transaction tran,
String dbid)
SQL文の実行結果において、データの件数を取得します(Transaction 対応)。
|
static String |
getProductName(Connection conn)
コネクションオブジェクトからデータベースのProductNameを取り出します。
|
static String[][] |
resultToArray(ResultSet resultSet,
boolean useHeader)
ResultSet より、結果の文字列配列を作成します。
|
public static String[][] dbExecute(String stmt, String[] args, ApplicationInfo appInfo)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクト3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 |
4.0.0.0 (2007/10/10) dbid の初期値を、"DEFAULT" から null に変更 |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static String[][] dbExecute(String stmt, String[] args, Transaction tran)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクト5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
public static String[][] dbExecute(String stmt, String[] args, ApplicationInfo appInfo, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクトdbid
- 接続先ID3.0.0.0 (2002/12/25) 検索のみのクエリーから、何でもありのクエリーに変更 |
2.3.1.3 (2003/01/28) Open Cursor が、大量に残る件の対応。ResultSet を close() |
3.8.0.8 (2005/10/03) エラーメッセージの出力順をメッセージ+Queryに変更します。 |
3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 |
4.0.0.1 (2007/12/03) try ~ catch ~ finally をきちんと行う。 |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static String[][] dbExecute(String stmt, String[] args, Transaction tran, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクトdbid
- 接続先ID5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
public static String[][] dbExecute(String stmt, String[] args, ApplicationInfo appInfo, String dbid, boolean useHeader)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクトdbid
- 接続先IDuseHeader
- 1行目にヘッダーを含めるか4.3.7.0 (2009/06/01) 新規作成 |
5.1.2.0 (2010/01/01) setObject に ParameterMetaData の getParameterType を渡す。(PostgreSQL対応) |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static String[][] dbExecute(String stmt, String[] args, Transaction tran, String dbid, boolean useHeader)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクトdbid
- 接続先IDuseHeader
- 1行目にヘッダーを含めるか5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
5.3.8.0 (2011/08/01) Transaction を引数で受け取った場合は、close() しない。 |
5.3.8.0 (2011/08/01) useParamMetaData を ConnectionFactory経由で取得。(PostgreSQL対応)、setNull 対応 |
6.4.2.1 (2016/02/05) try-with-resources 文で記述。 |
6.4.3.2 (2016/02/19) args が null でなく、length==0 でない場合のみ、処理する。 |
public static String[] dbCallExecute(String stmt, String[] args, ApplicationInfo appInfo)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクト3.8.0.0 (2005/06/07) 新規追加 |
3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 |
4.0.0.0 (2007/10/10) dbid の初期値を、"DEFAULT" から null に変更 |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static String[] dbCallExecute(String stmt, String[] args, Transaction tran)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクト5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
public static String[] dbCallExecute(String stmt, String[] args, ApplicationInfo appInfo, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクトdbid
- 接続先ID3.8.0.0 (2005/06/07) 新規追加 |
3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 |
4.0.0.1 (2007/12/03) try ~ catch ~ finally をきちんと行う。 |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static String[] dbCallExecute(String stmt, String[] args, Transaction tran, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクトdbid
- 接続先ID5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
5.3.8.0 (2011/08/01) Transaction を引数で受け取った場合は、close() しない。 |
6.4.2.1 (2016/02/05) try-with-resources 文で記述。 |
public static int dbExist(String stmt, String[] args, ApplicationInfo appInfo, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列appInfo
- アプリ情報オブジェクトdbid
- 接続先ID3.5.0.0 (2003/09/17) 新規作成 |
3.8.0.8 (2005/10/03) エラーメッセージの出力順をメッセージ+Queryに変更します。 |
3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 |
4.0.0.1 (2007/12/03) try ~ catch ~ finally をきちんと行う。 |
5.1.2.0 (2010/01/01) setObject に ParameterMetaData の getParameterType を渡す。(PostgreSQL対応) |
5.1.9.0 (2010/08/01) Transaction 対応します。 |
5.3.7.0 (2011/07/01) TransactionReal の引数変更 |
5.3.8.0 (2011/08/01) TransactionReal と close() 処理をセットで実行する。 |
6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。 |
public static int dbExist(String stmt, String[] args, Transaction tran, String dbid)
stmt
- ステートメント文字列args
- オブジェクトの引数配列tran
- Transactionオブジェクトdbid
- 接続先ID5.1.9.0 (2010/08/01) 新規作成 Transaction 対応 |
5.3.8.0 (2011/08/01) Transaction を引数で受け取った場合は、close() しない。 |
5.3.8.0 (2011/08/01) useParamMetaData を ConnectionFactory経由で取得。(PostgreSQL対応)、setNull 対応 |
6.4.2.1 (2016/02/05) try-with-resources 文で記述。 |
public static String[][] resultToArray(ResultSet resultSet, boolean useHeader) throws SQLException
resultSet
- ResultSetオブジェクトuseHeader
- true:ヘッダーを第一行に含める/false:含めないSQLException
- データベース・アクセス・エラーが発生した場合3.1.0.0 (2003/03/20) Vector を使用している箇所で、非同期でも構わない箇所を、ArrayList に置換え。 |
3.8.0.8 (2005/10/03) エラーメッセージの出力順をメッセージ+Queryに変更します。 |
4.0.0.0 (2005/01/31) private ⇒ public , ヘッダー情報の取得有無フラグの追加 |
5.6.7.0 (2013/07/27) CLOB 対応 |
6.0.4.0 (2014/11/28) ResultSetValue クラスで、ResultSet から値を取得する処理を行う。 |
public static String getProductName(Connection conn)
conn
- コネクションオブジェクト5.6.7.0 (2013/07/27) 新規追加 |
5.6.7.4 (2013/08/30) ProductNameの小文字化対応 |
6.7.4.2 (2017/02/24) ProductNameの大文字化対応 |
Webアプリケーションフレームワーク openGionCopyright (c) 2009 The openGion Project.