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