Package nablarch.core.db.connection
Class BasicDbConnection
java.lang.Object
nablarch.core.db.connection.BasicDbConnection
- All Implemented Interfaces:
- AppDbConnection,- TransactionManagerConnection
- Direct Known Subclasses:
- WmqXADbConnection
TransactionManagerConnectionの基本実装クラス。
 
 本オブジェクトは、マルチスレッド環境で使用されることは想定しない。すなわち、スレッドアンセーフなオブジェクトである。- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidコネクションをクローズする。
 Connection.close()を呼び出す。voidステートメントをクローズする。
 本データベースオブジェクトから生成されたステートメントオブジェクトを一括でクローズする。voidcommit()現在のデータベース接続に対してcommitを実行する。データベース接続オブジェクトを取得する。コネクションのDefaultDialectを取得する。voidデータベース接続の初期化処理を行う。prepareCall(String sql) ストアドプロシージャ実行用のStatementオブジェクトを生成する。prepareCallBySqlId(String sqlId) ストアドプロシージャ実行用のStatementオブジェクトをSQL_IDを元に生成する。SQL_IDを元に件数取得(カウント)用のStatementオブジェクトを生成する。prepareParameterizedCountSqlStatementBySqlId(String sqlId, Object condition) SQL_IDを元に件数取得(カウント)用のStatementオブジェクトを生成する。名前付きパラメータをもつSQL文実行用のStatementオブジェクトを生成する。prepareParameterizedSqlStatement(String sql, Object condition) 名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトを生成する。prepareParameterizedSqlStatement(String sql, Object condition, SelectOption selectOption) 検索範囲を指定して、名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトを生成する。prepareParameterizedSqlStatement(String sql, SelectOption selectOption) 検索範囲を指定した名前付きパラメータをもつSQL文実行用のStatementオブジェクトを生成する。名前付きパラメータをもつSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。prepareParameterizedSqlStatementBySqlId(String sqlId, Object condition) 名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。prepareParameterizedSqlStatementBySqlId(String sqlId, Object condition, SelectOption selectOption) 検索範囲を設定した名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。prepareParameterizedSqlStatementBySqlId(String sqlId, SelectOption selectOption) 検索範囲を設定した名前付きパラメータをもつSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。prepareStatement(String sql) パラメータ付きSQL文実行用のStatementオブジェクトを生成する。prepareStatement(String sql, int autoGeneratedKeys) 自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。prepareStatement(String sql, int[] columnIndexes) 自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。prepareStatement(String sql, String[] columnNames) 自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。prepareStatement(String sql, SelectOption selectOption) 検索範囲を指定したパラメータ付きSQL文実行用のStatementオブジェクトを生成する。prepareStatementBySqlId(String sqlId) パラメータ付きSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。prepareStatementBySqlId(String sqlId, SelectOption selectOption) 検索範囲を指定したパラメータ付きSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。voidremoveStatement(SqlStatement statement) 保持しているStatementを削除する。voidrollback()現在のデータベース接続に対してrollbackを実行する。voidsetContext(DbExecutionContext context) コンテキストを設定する。voidsetDbAccessExceptionFactory(DbAccessExceptionFactory dbAccessExceptionFactory) DbAccessExceptionファクトリオブジェクトを設定する。voidsetFactory(StatementFactory factory) StatementFactory実装クラスを設定する。voidsetIsolationLevel(int level) アイソレーションレベルを設定する。voidsetJdbcTransactionTimeoutHandler(JdbcTransactionTimeoutHandler jdbcTransactionTimeoutHandler) トランザクションタイムアウトハンドラを設定する。voidsetStatementReuse(boolean statementReuse) ステートメントのキャッシュ有無を設定する。voidデータベース接続の終了処理を行う。
 本処理では、下記処理を行う。 ロールバック処理(未確定のトランザクション情報は全て破棄する。) 本クラスで生成されたSqlStatementのクローズ処理 ステートメントキャッシュが有効な場合のキャッシュのクリア処理closeConnection()の呼び出し
- 
Constructor Details- 
BasicDbConnection指定されたデータ接続を保持するオブジェクトを生成する。- Parameters:
- con- データベース接続オブジェクト
 
 
- 
- 
Method Details- 
initializepublic void initialize()データベース接続の初期化処理を行う。
 下記処理を行う。 
 - Auto commitモードを無効化
 - Specified by:
- initializein interface- TransactionManagerConnection
 
- 
commitpublic void commit()現在のデータベース接続に対してcommitを実行する。- Specified by:
- commitin interface- TransactionManagerConnection
- See Also:
 
- 
rollbackpublic void rollback()現在のデータベース接続に対してrollbackを実行する。- Specified by:
- rollbackin interface- TransactionManagerConnection
 
- 
terminatepublic void terminate()データベース接続の終了処理を行う。
 本処理では、下記処理を行う。- ロールバック処理(未確定のトランザクション情報は全て破棄する。)
- 本クラスで生成されたSqlStatementのクローズ処理
- ステートメントキャッシュが有効な場合のキャッシュのクリア処理
- closeConnection()の呼び出し
 - Specified by:
- terminatein interface- TransactionManagerConnection
- See Also:
 
- 
closeConnectionコネクションをクローズする。
 Connection.close()を呼び出す。- Throws:
- SQLException- SQL例外
 
- 
setIsolationLevelpublic void setIsolationLevel(int level) アイソレーションレベルを設定する。- Specified by:
- setIsolationLevelin interface- TransactionManagerConnection
- Parameters:
- level- アイソレーションレベル(- Connectionで定義されている次の定数のうち1つを設定する。)
- See Also:
 
- 
prepareStatementDescription copied from interface:AppDbConnectionパラメータ付きSQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。- Specified by:
- prepareStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- Returns:
- PreparedStatementのラッパーstatement
- See Also:
 
- 
prepareStatementDescription copied from interface:AppDbConnection検索範囲を指定したパラメータ付きSQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるSqlPStatementは、あらかじめ検索範囲が設定されているため、SqlPStatement.retrieve(int, int)のような、検索範囲を指定した簡易検索処理は実行できない。
 SqlPStatement.retrieve()を使用すること。- Specified by:
- prepareStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- selectOption- 検索処理オプション
- Returns:
- PreparedStatementのラッパーstatement
- See Also:
 
- 
prepareStatementDescription copied from interface:AppDbConnection自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 自動生成されたキーは、SqlPStatement.getGeneratedKeys()を使用して取得する必要がある。- Specified by:
- prepareStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- autoGeneratedKeys- 自動生成キーを返すかどうかを示すフラグ。- Statement.RETURN_GENERATED_KEYSまたは- Statement.NO_GENERATED_KEYS
- Returns:
- 自動生成キーの取得機能を持つPreparedStatementのラッパーStatement
- See Also:
 
- 
prepareStatementDescription copied from interface:AppDbConnection自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 自動生成されたキーは、SqlPStatement.getGeneratedKeys()を使用して取得する必要がある。- Specified by:
- prepareStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- columnIndexes- 挿入された行から返される列を示す列インデックスの配列
- Returns:
- 自動生成キーの取得機能を持つPreparedStatementのラッパーStatement
- See Also:
 
- 
prepareStatementDescription copied from interface:AppDbConnection自動生成キー(データベース側で自動生成された値)を取得する機能を持つStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 自動生成されたキーは、SqlPStatement.getGeneratedKeys()を使用して取得する必要がある。- Specified by:
- prepareStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- columnNames- 挿入された行から返される列を示す列名の配列
- Returns:
- 自動生成キーの取得機能を持つPreparedStatementのラッパーStatement
- See Also:
 
- 
prepareStatementBySqlIdDescription copied from interface:AppDbConnectionパラメータ付きSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 指定されたSQL_IDに紐づくSQL文を取得し、Statementオブジェクトを生成する。
 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。- Specified by:
- prepareStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- Returns:
- PreparedStatementのラッパーStatement
- See Also:
 
- 
prepareStatementBySqlIdDescription copied from interface:AppDbConnection検索範囲を指定したパラメータ付きSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 指定されたSQL_IDに紐づくSQL文を取得し、Statementオブジェクトを生成する。
 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるSqlPStatementは、あらかじめ検索範囲が設定されているため、SqlPStatement.retrieve(int, int)のような、検索範囲を指定した簡易検索処理は実行できない。
 SqlPStatement.retrieve()を使用すること。- Specified by:
- prepareStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- selectOption- 検索処理オプション
- Returns:
- PreparedStatementのラッパーstatement
- See Also:
 
- 
prepareParameterizedSqlStatementDescription copied from interface:AppDbConnection名前付きパラメータをもつSQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。- Specified by:
- prepareParameterizedSqlStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementpublic ParameterizedSqlPStatement prepareParameterizedSqlStatement(String sql, SelectOption selectOption) Description copied from interface:AppDbConnection検索範囲を指定した名前付きパラメータをもつSQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。 注意:本メソッドで返却されるParameterizedSqlPStatementは、あらかじめ検索範囲が設定されているため、ParameterizedSqlPStatement.retrieve(int, int, Object)のような、検索範囲を指定した簡易検索処理は実行できない。- Specified by:
- prepareParameterizedSqlStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- selectOption- 検索処理オプション
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementBySqlIdDescription copied from interface:AppDbConnection名前付きパラメータをもつSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。- Specified by:
- prepareParameterizedSqlStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementBySqlIdpublic ParameterizedSqlPStatement prepareParameterizedSqlStatementBySqlId(String sqlId, SelectOption selectOption) Description copied from interface:AppDbConnection検索範囲を設定した名前付きパラメータをもつSQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。 注意:本メソッドで返却されるParameterizedSqlPStatementは、あらかじめ検索範囲が設定されているため、ParameterizedSqlPStatement.retrieve(int, int, Object)のような、検索範囲を指定した簡易検索処理は実行できない。- Specified by:
- prepareParameterizedSqlStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- selectOption- 検索処理オプション
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementDescription copied from interface:AppDbConnection名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。- Specified by:
- prepareParameterizedSqlStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- condition- 可変条件に設定される条件をもつオブジェクト
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementpublic ParameterizedSqlPStatement prepareParameterizedSqlStatement(String sql, Object condition, SelectOption selectOption) Description copied from interface:AppDbConnection検索範囲を指定して、名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトを生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。 注意:本メソッドで返却されるParameterizedSqlPStatementは、あらかじめ検索範囲が設定されているため、ParameterizedSqlPStatement.retrieve(int, int, Object)のような、検索範囲を指定した簡易検索処理は実行できない。- Specified by:
- prepareParameterizedSqlStatementin interface- AppDbConnection
- Parameters:
- sql- SQL文
- condition- 可変条件に設定される条件をもつオブジェクト
- selectOption- 検索処理オプション
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementBySqlIdpublic ParameterizedSqlPStatement prepareParameterizedSqlStatementBySqlId(String sqlId, Object condition) Description copied from interface:AppDbConnection名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。- Specified by:
- prepareParameterizedSqlStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- condition- 可変条件に設定される条件をもつオブジェクト
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedSqlStatementBySqlIdpublic ParameterizedSqlPStatement prepareParameterizedSqlStatementBySqlId(String sqlId, Object condition, SelectOption selectOption) Description copied from interface:AppDbConnection検索範囲を設定した名前付きパラメータをもつ可変条件SQL文実行用のStatementオブジェクトをSQL_IDを元に生成する。 Statementオブジェクトは、TransactionManagerConnection.terminate()メソッドで自動的にクローズされるため、 アプリケーションは、取得したStatementオブジェクトを明示的にクローズする必要はない。 注意:本メソッドで返却されるParameterizedSqlPStatementは、名前付きパラメータをもつSQL文専用である。 このため、通常のバインド変数(バインド変数を「?」で表すもの)をもつSQL文の場合は、 本メソッドで生成したParameterizedSqlPStatementでは処理できないことに注意すること。 注意:本メソッドで返却されるParameterizedSqlPStatementは、あらかじめ検索範囲が設定されているため、ParameterizedSqlPStatement.retrieve(int, int, Object)のような、検索範囲を指定した簡易検索処理は実行できない。- Specified by:
- prepareParameterizedSqlStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- condition- 可変条件に設定される条件をもつオブジェクト
- selectOption- 検索処理オプション
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareParameterizedCountSqlStatementBySqlIdpublic ParameterizedSqlPStatement prepareParameterizedCountSqlStatementBySqlId(String sqlId, Object condition) SQL_IDを元に件数取得(カウント)用のStatementオブジェクトを生成する。 SQL文を件数取得(カウント)用に変換すること以外は、AppDbConnection.prepareParameterizedSqlStatementBySqlId(String, Object)と同じ処理を行う。 件数取得用のSQLへの変換は、Dialect.convertCountSql(String)で行う。- Specified by:
- prepareParameterizedCountSqlStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- condition- 可変条件に設定される条件をもつオブジェクト
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareCountStatementBySqlIdSQL_IDを元に件数取得(カウント)用のStatementオブジェクトを生成する。 SQL文を件数取得(カウント)用に変換すること以外は、AppDbConnection.prepareStatementBySqlId(String)と同じ処理を行う。 件数取得用のSQLへの変換は、Dialect.convertCountSql(String)で行う。- Specified by:
- prepareCountStatementBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareCallDescription copied from interface:AppDbConnectionストアドプロシージャ実行用のStatementオブジェクトを生成する。- Specified by:
- prepareCallin interface- AppDbConnection
- Parameters:
- sql- SQL文
- Returns:
- Statementオブジェクト
- See Also:
 
- 
prepareCallBySqlIdDescription copied from interface:AppDbConnectionストアドプロシージャ実行用のStatementオブジェクトをSQL_IDを元に生成する。- Specified by:
- prepareCallBySqlIdin interface- AppDbConnection
- Parameters:
- sqlId- SQL_ID
- Returns:
- Statementオブジェクト
- See Also:
 
- 
closeStatementspublic void closeStatements()ステートメントをクローズする。
 本データベースオブジェクトから生成されたステートメントオブジェクトを一括でクローズする。
- 
setFactoryStatementFactory実装クラスを設定する。- Parameters:
- factory-- StatementFactory実装クラス
 
- 
setStatementReusepublic void setStatementReuse(boolean statementReuse) ステートメントのキャッシュ有無を設定する。- Parameters:
- statementReuse- ステートメントのキャッシュ有無
 
- 
setDbAccessExceptionFactoryDbAccessExceptionファクトリオブジェクトを設定する。- Parameters:
- dbAccessExceptionFactory-- DbAccessExceptionファクトリオブジェクト
 
- 
setJdbcTransactionTimeoutHandlerpublic void setJdbcTransactionTimeoutHandler(JdbcTransactionTimeoutHandler jdbcTransactionTimeoutHandler) Description copied from interface:TransactionManagerConnectionトランザクションタイムアウトハンドラを設定する。- Specified by:
- setJdbcTransactionTimeoutHandlerin interface- TransactionManagerConnection
- Parameters:
- jdbcTransactionTimeoutHandler- トランザクションタイムアウトハンドラ
 
- 
getConnectionDescription copied from interface:TransactionManagerConnectionデータベース接続オブジェクトを取得する。- Specified by:
- getConnectionin interface- TransactionManagerConnection
- Returns:
- データベース接続オブジェクト
 
- 
getDialectDescription copied from interface:TransactionManagerConnectionコネクションのDefaultDialectを取得する。- Specified by:
- getDialectin interface- TransactionManagerConnection
- Returns:
- SQL方言
 
- 
setContextコンテキストを設定する。- Parameters:
- context- コンテキスト
 
- 
removeStatementDescription copied from interface:TransactionManagerConnection保持しているStatementを削除する。- Specified by:
- removeStatementin interface- TransactionManagerConnection
- Parameters:
- statement- 削除対象のステートメント
 
 
-