001/* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016package org.opengion.fukurou.db; 017 018import org.opengion.fukurou.util.AbstractObjectPool; 019import org.opengion.fukurou.util.ApplicationInfo; 020import org.opengion.fukurou.util.Closer; 021 022import java.util.Map; 023import java.util.HashMap; 024import java.util.Locale; 025import java.util.Properties; 026import java.sql.Connection; 027import java.sql.SQLException; 028import java.sql.DriverManager; 029import java.sql.DatabaseMetaData; 030 031/** 032 * データベースのコネクションオブジェクトを取得する為に使用する,ファクトリクラスです。 033 * 034 * Connection.connection() メソッドで,Connectionオブジェクトを取得します。 035 * Connection#close() メソッドで,内部的に ConnectionFactory にオブジェクトを戻す 036 * 事によって,Connectionオブジェクトのプーリングを行なっています。 037 * 038 * コネクションオブジェクトは,プールから貸し出します。 039 * つまり,貸し出し中には,プールには,オブジェクトは残っていません。 040 * その状態で,コネクションオブジェクトをclose()しない場合は,オブジェクトが破棄されて, 041 * 貸し出し中カウントと実際のオブジェクト数が食い違い,リソースが不足します。 042 * 必ず,作成したオブジェクトは,close()メソッドを呼び出して,プールに返して下さい。 043 * 044 * システムリソースの USE_DB_APPLICATION_INFO=true の場合、コネクションにアプリケーション 045 * 情報を追記するため、ApplicationInfoオブジェクトを使用します。 046 * このオブジェクトは、jsp/common/session-init.jsp にてユーザー情報とアプリケーション 047 * 情報を画面アクセスごとに設定します。 048 * 049 * @og.group DB/Shell制御 050 * @og.rev 4.0.0.0 (2007/10/16) パッケージ移動(hayabusa/db ⇒ fukurou/db) 051 * 052 * @version 4.0 053 * @author Kazuhiko Hasegawa 054 * @since JDK5.0, 055 */ 056public final class ConnectionFactory { 057 private static final Map<String,ConnectionPool> map = new HashMap<String,ConnectionPool>(); 058 059 // 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 060 // 4.0.0.0 (2007/10/29) 初期値をここでセットする 061 private static String DBID = "DEFAULT"; 062 private static ConnectionPool DEF_POOL ; 063 064 // 4.0.0.0 (2007/10/17) システム依存の改行記号をセットします。 065 private static final String CR = System.getProperty( "line.separator" ); 066 067 // 4.0.0.0 (2007/10/25) hayabusa依存を切るために追加します 068 private static final int BUFFER_MIDDLE = 200; 069 070 private static DatabaseConfig dbc; 071 072 /** 073 * デフォルトコンストラクターをprivateにして、 074 * オブジェクトの生成をさせないようにする。 075 * 076 */ 077 private ConnectionFactory() { 078 } 079 080 /** 081 * 初期化メソッドです。 082 * <pre> 083 * 1)第二引数にXMLファイルをクラスローダ基底からの相対パスで指定した場合は 084 * そのXMLを利用してDBConfigオブジェクトを作成します。例:ConnectionFactory.init( CONTEXT_NAME, "../DBConfig.xml") 085 * nullの場合はWEB-INF/DBConfig.xmlを利用します。例:ConnectionFactory.init( CONTEXT_NAME, null) 086 * 2)キャッシュ初期ConnectionPoolのキーを設定してキャッシュプールを作ります。 087 * この値がnullの場合は"DEFAULT"が設定されます。 088 * </pre> 089 * 090 * <strong>このクラスを利用する場合は必ず最初にこのメソッドを実行する必要があります。</strong> 091 * キャッシュとDBConfigオブジェクトの同期化はされていないので初期化以外での利用は避けて下さい。 092 * 093 * @og.rev 4.0.0.0 (2007/11/05) 新規作成 094 * 095 * @param defPoolKey 初期DBID名(nullの場合は、"DEFAULT") 096 * @param xmlFileName DBConfig.xmlファイルのファイル名(nullの場合は、WEB-INF/DBConfig.xml) 097 */ 098 public static void init( final String defPoolKey, final String xmlFileName ) { 099 // DBConfigオブジェクトの作成 100 if( xmlFileName == null || xmlFileName.length() == 0 ) { 101 dbc = new DatabaseConfig(); 102 } 103 else { 104 dbc = new DatabaseConfig( xmlFileName ); 105 } 106 107 if( defPoolKey == null || defPoolKey.length() == 0 || dbc.getDbid( defPoolKey ) == null ) { 108 DBID = "DEFAULT"; 109 } 110 else { 111 DBID = defPoolKey; 112 } 113 EDbid edbid = dbc.getDbid( DBID ); 114 if( edbid == null ) { 115 final String errMsg = "初期化時に、指定のDBIDキーが存在しません。" 116 + "[Key =" 117 + DBID 118 + "]"; 119 throw new RuntimeException( errMsg ); 120 } 121 122 DEF_POOL = new ConnectionPool( edbid ); 123 } 124 125 /** 126 * コネクションオブジェクトを取得します。 127 * 遅い初期化を行なう事により,実際に必要となるまでコネクションオブジェクトは 128 * 作成しません。 129 * 最大プール数に達して,なおかつ,すべてのConnectionが貸し出し中の場合, 130 * 131 * @og.rev 2.1.1.3 (2002/11/22) コネクションID が null の場合に DEFAULT から所得するように変更。 132 * @og.rev 3.1.0.0 (2003/03/20) Hashtable を使用している箇所で、非同期でも構わない箇所を、HashMap に置換え。 133 * @og.rev 3.5.6.2 (2004/07/05) 文字列の連結にStringBuilderを使用します。 134 * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定 135 * @og.rev 3.8.8.2 (2007/01/26) USE_DB_APPLICATION_INFO ⇒ pool.useApplicationInfo() 変更 136 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 137 * @og.rev 4.1.0.1 (2008/01/21) 登録時に、大文字に変換する。 138 * 139 * @param dbid 接続先ID 140 * @param appInfo アプリ情報オブジェクト 141 * 142 * @return コネクションオブジェクト 143 */ 144 public static Connection connection( final String dbid , final ApplicationInfo appInfo ) { 145 ConnectionPool pool ; 146 if( dbid == null || dbid.length() == 0 || DBID.equalsIgnoreCase( dbid ) ) { 147 pool = DEF_POOL ; 148 } 149 else { 150 String udbid = dbid.toUpperCase( Locale.JAPAN ); // 大文字化 151 synchronized( map ) { 152 pool = map.get( udbid ); 153 // 接続IDが、map に存在しない場合 154 if( pool == null ) { 155 EDbid edbid = dbc.getDbid( udbid ); 156 if( edbid == null ) { 157 final String errMsg = "指定のDBIDキーが存在しません。" 158 + "[Key =" 159 + udbid 160 + "]"; 161 throw new RuntimeException( errMsg ); 162 } 163 pool = new ConnectionPool( edbid ); 164 map.put( udbid,pool ); 165 } 166 } 167 } 168 169 Connection conn = pool.newInstance(); 170 171 // 3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを使用 172 // 3.8.8.2 (2007/01/26) ORACLE 以外は、使用しません。 173 // 4.0.0.0 (2007/11/29) 入れ子if の統合 174 if( appInfo != null && pool.useApplicationInfo() ) { 175 appInfo.callAppInfo( conn ); 176 } 177 return conn; 178 } 179 180 /** 181 * コネクションオブジェクトをプールに戻します。 182 * Connectionオブジェクトは,close()メソッドで,自分自身を ConnectionFactory の 183 * プールに戻します。 184 * それ以外の コネクションオブジェクトをプールに戻す場合は,このメソッドを使用します。 185 * 186 * @og.rev 2.1.1.3 (2002/11/22) コネクションID が null の場合に DEFAULT から所得するように変更。 187 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 188 * @og.rev 4.1.0.1 (2008/01/21) 登録時に、大文字に変換する。 189 * @og.rev 5.9.32.0 (2018/05/18) プールに戻す前に明示的にcommitをかける 190 * 191 * @param conn コネクションオブジェクト 192 * @param dbid 接続先ID 193 */ 194 public static void close( final Connection conn,final String dbid ) { 195 if( conn != null ) { 196 Closer.commit( conn ); // 5.9.32.0 (2018/05/18) プールに戻す前に明示的にcommitをかける 197 if( dbid == null || dbid.length() == 0 || DBID.equalsIgnoreCase( dbid ) ) { 198 DEF_POOL.release( conn ) ; 199 } 200 else { 201 String udbid = dbid.toUpperCase( Locale.JAPAN ); // 大文字化 202 synchronized( map ) { 203 ConnectionPool pool = map.get( udbid ); 204 if( pool != null ) { 205 pool.release( conn ); 206 } 207 } 208 } 209 } 210 } 211 212 /** 213 * コネクションオブジェクトを物理的に削除(クローズ)戻します。 214 * これは、コネクション等がエラーを起こした場合に、プールに戻すのではなく、 215 * 接続を閉じる場合に、使用されます。 216 * 217 * @og.rev 2.1.1.3 (2002/11/22) コネクションID が null の場合に DEFAULT から所得するように変更。 218 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 219 * @og.rev 4.1.0.1 (2008/01/21) 登録時に、大文字に変換する。 220 * 221 * @param conn コネクションオブジェクト 222 * @param dbid 接続先ID 223 */ 224 public static void remove( final Connection conn,final String dbid ) { 225 if( conn != null ) { 226 if( dbid == null || dbid.length() == 0 || DBID.equalsIgnoreCase( dbid ) ) { 227 DEF_POOL.remove( conn ) ; 228 } 229 else { 230 String udbid = dbid.toUpperCase( Locale.JAPAN ); // 大文字化 231 synchronized( map ) { 232 ConnectionPool pool = map.get( udbid ); 233 if( pool != null ) { 234 pool.remove( conn ); 235 // map.put( udbid,pool ); 236 } 237 } 238 } 239 } 240 } 241 242 /** 243 * コネクションオブジェクトを実際にすべてクローズします。 244 * コネクションプールの再編成や,管理者による強制クローズに使用します。 245 * 246 * クローズに失敗(コネクションが貸し出し中)の場合は,内部的に 247 * DB_CLOSE_RETRY_TIME だけ待機して, DB_CLOSE_RETRY_COUNT 回数だけ,試行します。 248 * それでもクローズできない場合は, RuntimeException を throw します。 249 * 250 * @og.rev 4.0.0.0 (2005/01/31) ロジック見直し。 pool.clear() で、基本的にはすべて削除されます。 251 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 252 */ 253 public static void realClose() { 254 synchronized( DEF_POOL ) { 255 if( ! DEF_POOL.isEmpty() ) { 256 DEF_POOL.clear(); 257 } 258 } 259 260 final ConnectionPool[] pools ; 261 synchronized( map ) { 262 if( map.isEmpty() ) { return; } 263 264 pools = map.values().toArray( new ConnectionPool[map.size()] ) ; 265 map.clear(); 266 } 267 268 ConnectionPool pool ; 269 for( int i=0; i<pools.length ; i++ ) { 270 pool = pools[i]; 271 if( pool != null && ! pool.isEmpty() ) { 272 pool.clear(); 273 } 274 } 275 } 276 277 /** 278 * ConnectionFactory の現在の状況(詳細メッセージ)を返します。 279 * これは,コネクションプールの数(最大値,作成済み数など)を確認する為のものです。 280 * 281 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 282 * 283 * @return 現在の状態表示 284 */ 285 public static String information() { 286 return information( true ); 287 } 288 289 /** 290 * ConnectionFactory の現在の状況を返します。 291 * これは,コネクションプールの数(最大値,作成済み数など)を確認する為のものです。 292 * 引数により詳細メッセージかどうかを指定できます。 293 * 294 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 295 * @og.rev 5.3.4.0 (2011/04/01) 詳細メッセージ用引数を追加 296 * @og.rev 5.6.7.3 (2013/08/23) 若干の修正 297 * 298 * @param isDetail 詳細メッセージかどうか [true:詳細メッセージ/false:簡易メッセージ] 299 * 300 * @return 現在の状態表示 301 */ 302 public static String information(final boolean isDetail ) { 303 // 4.0.0.0 (2007/10/25) hybsとの依存関係を弱めるため。 304 final StringBuilder strBuf = new StringBuilder( BUFFER_MIDDLE ); 305 306 strBuf.append( "<b>【Connection Information】</b>" ).append( CR ); // 5.6.7.3 (2013/08/23) 若干の修正 307 308 int rtnCnt = 0; 309 synchronized( DEF_POOL ) { 310 if( ! DEF_POOL.isEmpty() ) { 311 rtnCnt += DEF_POOL.size(); 312 // 5.3.4.0 (2011/04/01) 詳細メッセージ用引数を追加 313 if( isDetail ) { 314 strBuf.append( DEF_POOL.toString() ); 315 strBuf.append( "<br /><hr />" ); 316 } 317 else { 318 strBuf.append( DEF_POOL.dbidInfo() ); 319 } 320 } 321 } 322 323 ConnectionPool[] pools = null; 324 synchronized( map ) { 325 if( !map.isEmpty() ) { 326 pools = map.values().toArray( new ConnectionPool[map.size()] ) ; 327 } 328 } 329 330 if( pools != null ) { 331 for( int i=0; i<pools.length ; i++ ) { 332 ConnectionPool pool = pools[i]; 333 if( pool != null && ! pool.isEmpty() ) { 334 rtnCnt += pool.size(); 335 // 5.3.4.0 (2011/04/01) 詳細メッセージ用引数を追加 336 if( isDetail ) { 337 strBuf.append( pool.toString() ); 338 strBuf.append( "<br /><hr />" ); 339 } 340 else { 341 strBuf.append( pool.dbidInfo() ); 342 } 343 } 344 } 345 } 346 347 strBuf.append( CR ); 348 349 return strBuf.toString(); 350 } 351 352 /** 353 * この接続が、PreparedStatement#getParameterMetaData() を使用するかどうかを判定します。 354 * 355 * PreparedStatement に対して、String化された 数字などを setObject( int,String ) するとき、 356 * ORACLE と SQLServer は、そのまま設定すれば、自動的に変換されます。 357 * postgreSQL では、ParameterMetaData#getParameterType(int) で、カラムタイプを取得し、 358 * setObject( int,String,int ) する必要があります。 359 * その判定に、このメソッドを使用します。 360 * この結果は、あくまで、各種データベース毎の実地調査の結果を元に、判定結果を 361 * 返すようにしています。 362 * ORACLE の場合は、使用しない(false)が返るように設定しています。 363 * SQLServer では、ORACLEと同様に、false を返します。 364 * 365 * このメソッドは、元々、ApplicationInfo#useParameterMetaData(Connection) に有ったものを 366 * EDbid から取得するように修正したものです。 367 * 368 * @og.rev 5.3.8.0 (2011/08/01) 新規追加 369 * 370 * @param dbid 接続先ID 371 * 372 * @return [true:使用する/false:その他] 373 */ 374 public static boolean useParameterMetaData( final String dbid ) { 375 final String udbid ; 376 if( dbid == null || dbid.length() == 0 ) { 377 udbid = DBID ; 378 } 379 else { 380 udbid = dbid.toUpperCase( Locale.JAPAN ); // 大文字化 381 } 382 383 EDbid edbid = dbc.getDbid( udbid ); 384 385 return edbid.useParamMetaData(); 386 } 387 388 /** 389 * 接続先のDB名に対応した、enum (DBName) を返します(toUpperCase)。 390 * 391 * @og.rev 5.1.4.0 (2010/03/01) getDBFullName の代わりに新規作成 392 * @og.rev 5.7.7.2 (2014/06/20) 最初の取得時のエラー回避 393 * 394 * @param dbid 接続先ID 395 * 396 * @return 接続先のDB名 397 */ 398 public static String getDBName( final String dbid ) { 399 final String dbName; 400 401 if( dbid == null || dbid.length() == 0 || DBID.equalsIgnoreCase( dbid ) ) { 402 dbName = DEF_POOL.getDBName(); 403 } 404 else { 405 String udbid = dbid.toUpperCase( Locale.JAPAN ); // 大文字化 406 ConnectionPool pool = null; 407 synchronized( map ) { 408 pool = map.get( udbid ); 409 if( pool == null ) { 410// close( connection( dbid, null ), dbid ); // 5.7.7.2 (2014/06/20) 最初の取得時のエラー回避 411 connection( dbid, null ); // ダミーで、コネクトする。 412 pool = map.get( udbid ); // もう一度、設定する。 413 } 414 } 415 if( pool != null ) { 416 dbName = pool.getDBName(); 417 } 418 else { 419 final String errMsg = "指定のDBIDキーに対応するデータベース名を取得出来ません。" 420 + "[Key =" + dbid + "]"; 421 throw new RuntimeException( errMsg ); 422 } 423 } 424 425 return dbName.toUpperCase( Locale.JAPAN ); 426 } 427} 428 429/** 430 * ConnectionPool は、AbstractObjectPool を継承した オブジェクトプールです。 431 * 432 * コネクションオブジェクトをプールすることにより、ConnectionFactory で 433 * 管理する Map オブジェクトの実態として、各ID毎の コネクションをキープします。 434 * 435 * @og.group DB/Shell制御 436 * 437 * @version 4.0 438 * @author Kazuhiko Hasegawa 439 * @since JDK5.0, 440 */ 441class ConnectionPool extends AbstractObjectPool<Connection> { 442 private final transient EDbid edbid; 443 444 // 4.0.0.0 (2007/10/17) システム依存の改行記号をセットします。 445 private static final String CR = System.getProperty( "line.separator" ); 446 447 /** 448 * DBID を指定して作成する コンストラクター 449 * DBID をキーに、 HybsSystem.sys メソッドのデータベース変数を取得します。 450 * 取得するのは、 DBID + _DB_URL/_DB_USER/_DB_PASSWD/_DB_MINCOUNT/_DB_MAXCOUNT 451 * です。 452 * DBID が null の場合は,"DEFAULT" が使用されます。 453 * 454 * @og.rev 3.5.4.3 (2004/01/05) キャッシュの寿命を指定 455 * @og.rev 3.5.4.7 (2004/02/06) DBID のゼロストリングチェック追加 456 * @og.rev 4.0.0.0 (2007/10/10) キャッシュされた、初期ConnectionPool を使用 457 * @og.rev 4.0.0.0 (2007/10/25) DB設定情報のXML化に伴う変更 458 * 459 * @param edbid 接続先情報オブジェクト 460 */ 461 public ConnectionPool( final EDbid edbid ) { 462 // 4.0.0.0 XML化に伴いロード先を変更 463 this.edbid = edbid; 464 init( edbid.getMincount(),edbid.getMaxcount(),true,edbid.getPooltime() ); 465 } 466 467 /** 468 * オブジェクトプールから削除するときに呼ばれます。 469 * このメソッドで各オブジェクトごとの終了処理を行います。 470 * 例えば、データベースコネクションであれば、close() 処理などです。 471 * 472 * @og.rev 3.5.4.8 (2004/02/23) SQLException は無視します。 473 * @og.rev 3.5.6.0 (2004/06/18) synchronized を解除します。 474 * 475 * @param obj 終了処理を行うオブジェクト 476 */ 477 protected void objectFinal( final Connection obj ) { 478 Closer.connClose( obj ); 479 } 480 481 /** 482 * コネクションオブジェクトを作成します。 483 * DriverManager.getConnection により作成されたConnection を Connection で 484 * ラッピングします。 485 * Connectionオブジェクトは,close()メソッドで,自分自身を ConnectionFactory の 486 * プールに戻します。 487 * 488 * @og.rev 3.3.3.3 (2003/08/06) コネクションに対して、setTransactionIsolation を、設定しておく。 489 * @og.rev 3.5.2.0 (2003/10/20) 接続情報に、データベース名、ドライバ名情報を追加する。 490 * @og.rev 3.5.6.0 (2004/06/18) synchronized を解除します。 491 * @og.rev 3.8.8.2 (2007/01/26) useAppInfo を設定します。 492 * @og.rev 4.0.0.0 (2007/10/30) 保持情報オブジェクト化に伴う変更 493 * @og.rev 5.1.2.0 (2010/01/01) MySQL対応 明示的に、TRANSACTION_READ_COMMITTED を指定する。 494 * @og.rev 5.5.2.0 (2012/05/01) properties対応 495 * 496 * @return コネクションオブジェクト 497 */ 498 protected Connection createInstance() { 499 Connection conn = null; 500 try { 501 // DriverManager.setLogWriter( HybsSystem.out ); // ドライバーのログ 502 503 // 5.5.2.0 (2012/05/01) propertyの追加処理と、接続のproperties化 504 Properties prop = new Properties (edbid.getProps()); 505 prop.put ( "user", edbid.getUser() ); 506 prop.put ( "password", edbid.getPassword() ); 507 508 conn = DriverManager.getConnection( edbid.getUrl(), prop ); 509 // conn.setReadOnly( true ); 510 conn.setReadOnly( edbid.isReadonly() ); 511 512 conn.setAutoCommit( false ); 513 conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); // 初期値 514 // ((OracleConnection)conn).setDefaultExecuteBatch(1); // 初期値 515 // ((OracleConnection)conn).setDefaultRowPrefetch(20); // 初期値 516 517 // 3.5.2.0 (2003/10/20) 接続情報に、データベース名、ドライバ名情報を追加する。 518 // 4.0.0.0 (2007/10/26) 登録先をオブジェクト化 519 if( edbid.getDbProductName() == null ) { 520 DatabaseMetaData meta = conn.getMetaData(); 521 edbid.setMetaDataInfo( meta ); 522 } 523 return conn ; 524 } 525 catch ( SQLException ex ) { 526 String errMsg = "コネクトすることが出来ません。" + CR 527 + "DBID=[" + edbid.getDbidKey() + "]" + CR 528 + ex.getMessage() + " , status=" + ex.getSQLState(); 529 Closer.connClose( conn ); 530 throw new RuntimeException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び順変更 531 } 532 } 533 534 /** 535 * アクセスログ取得の為のDBMS_APPLICATION_INFOの使用可否を取得します(初期値:true)。 536 * 537 * データベースへのアクセスログ取得の為、エンジンで接続するコネクションについて 538 * DBMS_APPLICATION_INFO.SET_CLIENT_INFO と SET_MODULE を呼び出しています。 539 * この処理は、ORACLEとの接続のみ有効ですので、接続先データベースが ORACLE 以外は 540 * false を返します。 541 * ORACLE の場合は、システムリソースの USE_DB_APPLICATION_INFO 属性の設定値を 542 * 返します。 543 * この設定値の初期値は、true です。 544 * 545 * @og.rev 3.8.8.2 (2007/01/26) 新規追加 546 * 547 * @return true:使用する/false:使用しない 548 */ 549 public boolean useApplicationInfo() { return edbid.isApplicationInfo(); } 550 551 /** 552 * 接続先のDB名を返します。 553 * 554 * @og.rev 4.3.7.0 (2009/06/01) 新規作成 555 * 556 * @return 接続先のDB名 557 */ 558 public String getDBName() { 559 return edbid.getDbProductName(); 560 } 561 562 /** 563 * 接続先のDBバージョンを返します。 564 * 565 * @og.rev 4.3.7.0 (2009/06/01) 新規作成 566 * 567 * @return 接続先のDBバージョン 568 */ 569 public String getDBVersion() { 570 return edbid.getDbProductVersion(); 571 } 572 573 /** 574 * 接続先の簡易な内部情報を返します。 575 * 576 * @og.rev 5.3.4.0 (2011/04/01) toString() の簡易版 577 * 578 * @return 接続先の簡易な内部情報 579 */ 580 public String dbidInfo() { 581 return edbid.info(); 582 } 583 584 /** 585 * 内部状況を簡易的に表現した文字列を返します。 586 * DBID/URL/USER/プールサイズ を返します。 587 * 588 * @og.rev 3.5.2.0 (2003/10/20) 接続情報に、データベース名、ドライバ名情報を追加する。 589 * @og.rev 3.5.6.6 (2004/08/23) 同期化方法を統一する為、synchronized をつけます。(別途 要検討) 590 * @og.rev 4.0.0.0 (2007/10/29) EDbidのtoStringを呼ぶように変更 591 * 592 * @return このオブジェクトプールの文字列表現 593 */ 594 @Override 595 public String toString() { 596 StringBuilder buf = new StringBuilder(); 597 buf.append( edbid.toString() ); 598 buf.append( super.toString() ); 599 return buf.toString(); 600 } 601}