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