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.hayabusa.db;
017
018 import java.sql.Connection;
019 import java.sql.ResultSet;
020 import java.sql.SQLException;
021
022 import org.opengion.fukurou.db.Transaction;
023 import org.opengion.fukurou.db.ConnectionFactory; // 5.3.8.0 (2011/08/01)
024 import org.opengion.fukurou.util.ErrorMessage;
025 import org.opengion.hayabusa.common.HybsSystem;
026 import org.opengion.hayabusa.common.HybsSystemException;
027 import org.opengion.hayabusa.resource.ResourceManager;
028
029 /**
030 * Query インターフェースを継承した Query の実?ラスです?
031 * クエリークラスにス??トメントを与えて execute()することにより?に DBTableModel ?
032 * 作?します?
033 * こ?クラスは、Abstract クラスのため、実??個?のサブクラスで行います?
034 * 唯??る?があるのは, execute() メソ??です?
035 *
036 * @og.group ??検索
037 * @og.group ??登録
038 *
039 * @version 4.0
040 * @author Kazuhiko Hasegawa
041 * @since JDK5.0,
042 */
043 public class AbstractQuery implements Query {
044 private Connection connection = null ;
045 private Transaction transaction = null ; // 5.1.9.0 (2010/08/01)
046 private int rtnCode = ErrorMessage.OK;
047 private ErrorMessage errMessage = null;
048 private ResourceManager resource = null;
049 // private ApplicationInfo appInfo = null; // 5.1.9.0 (2010/08/01) ローカル?
050
051 private DBTableModel table = null;
052 private String connID = null;
053 private String stmtString = null;
054 private int executeCount = -1 ;
055 private int skipRowCount = 0 ;
056 private int maxRowCount = HybsSystem.sysInt( "DB_MAX_ROW_COUNT" ) ;
057 private boolean updateFlag = true ;
058 private DBEditConfig config = null; // 5.3.6.0 (2011/06/01)
059
060 // 5.1.9.0 (2010/08/01) DB_RETRY_COUNT,DB_RETRY_TIME ?
061 // private static final int DB_RETRY_COUNT = HybsSystem.sysInt( "DB_RETRY_COUNT" ) ;
062 // private static final int DB_RETRY_TIME = HybsSystem.sysInt( "DB_RETRY_TIME" ) ;
063 protected static final int DB_MAX_QUERY_TIMEOUT = HybsSystem.sysInt( "DB_MAX_QUERY_TIMEOUT" ) ;
064
065 // 3.5.2.0 (2003/10/20) ?オブジェクトタイプ名?シス?パラメータ で定義します?
066 /** ?オブジェクトタイプ名 {@value} */
067 public static final String ARG_ARRAY = "ARG_ARRAY" ;
068 /** ?オブジェクトタイプ名 {@value} */
069 public static final String SYSARG_ARRAY = "SYSARG_ARRAY" ;
070 /** ?オブジェクトタイプ名 {@value} */
071 public static final String ERR_MSG = "ERR_MSG" ;
072 /** ?オブジェクトタイプ名 {@value} */
073 public static final String ERR_MSG_ARRAY = "ERR_MSG_ARRAY" ;
074
075 /**
076 * Queryオブジェクトを初期化します?
077 * これは、QueryFactory のプ?ルから取り出すときに(また?戻すと?に
078 * 初期化する?に使用します?
079 *
080 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
081 * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得?為,ApplicationInfoオブジェクトを設?
082 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?(外部Transactionの使用)追?
083 * @og.rev 5.3.6.0 (2011/06/01) DBEditConfig 追?
084 *
085 */
086 public void init() {
087 close(); // 先にクローズ処?行います?(transaction = null がセ?)
088 rtnCode = ErrorMessage.OK;
089 errMessage = null;
090 resource = null;
091 // appInfo = null; // 5.1.9.0 (2010/08/01) ローカル?
092 table = null;
093 connID = null;
094 stmtString = null;
095 executeCount = -1 ;
096 skipRowCount = 0 ;
097 maxRowCount = HybsSystem.sysInt( "DB_MAX_ROW_COUNT" ) ;
098 updateFlag = true ;
099 connection = null; // 5.1.9.0 (2010/08/01) キャ?ュの初期?
100 config = null; // 5.3.6.0 (2011/06/01) DBEditConfig追?
101 }
102
103 /**
104 * ス??トメント文字?をセ?します?
105 *
106 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
107 *
108 * @param stmt ス??トメント文字?
109 *
110 */
111 public void setStatement( final String stmt ) {
112 this.stmtString = stmt.trim();
113 }
114
115 /**
116 * ス??トメント文字?を取り?します?
117 *
118 * @return ス??トメント文字?
119 *
120 */
121 public String getStatement() {
122 return stmtString;
123 }
124
125 /**
126 * クエリーを実行します?
127 * 実行方法等??ブクラスの実?依存します?
128 * セ?されて?ス??トメント文字?とそ?タイプが合って???合?,
129 * エラーになります?
130 * 実行結果は、DBTableModel にセ?されます?
131 * 実行結果の件数は #getExecuteCount() で取得できます?
132 * ※ こ?クラスでは実?れて?せん?
133 *
134 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
135 *
136 */
137 public void execute() {
138 String errMsg = "こ?クラスでは実?れて?せん。execute()";
139 throw new UnsupportedOperationException( errMsg );
140 }
141
142 /**
143 * 引数配?付?クエリーを実行します?
144 * 処??体?, #execute() と同様に、各サブクラスの実?依存します?
145 * これは、PreparedQuery で使用する引数を?列でセ?するも?です?
146 * select * from emp where deptno = ? and job = ? などの PreparedQuery ?
147 * { call xxxx( ?,?,? ) } などの CallableStatement の ? 部??引数?
148 * ?にセ?して?ます?
149 * ※ こ?クラスでは実?れて?せん?
150 *
151 * @param args オブジェクト?引数配?
152 */
153 public void execute( final String[] args ) {
154 String errMsg = "こ?クラスでは実?れて?せん。execute( String[] )";
155 throw new UnsupportedOperationException( errMsg );
156 }
157
158 /**
159 * 引数配?付?クエリーを実行します?
160 * 処??体?, #execute() と同様に、各サブクラスの実?依存します?
161 * これは、PreparedQuery で使用する引数を?列でセ?するも?です?
162 * select * from emp where deptno = ? and job = ? などの PreparedQuery の
163 * ? 部??引数?
164 * ?にセ?して?ます?
165 * ※ こ?クラスでは実?れて?せん?
166 *
167 * @og.rev 4.0.0.0 (2005/01/31) 新規追?
168 *
169 * @param keys オブジェクト?キー配?
170 * @param args オブジェクト?引数配?
171 */
172 public void execute( final String[] keys, final String[] args ) {
173 String errMsg = "こ?クラスでは実?れて?せん。execute( String[],String[] )";
174 throw new UnsupportedOperationException( errMsg );
175 }
176
177 /**
178 * 引数配?付?クエリーを実行します?
179 * 処??体?, #execute() と同様に、各サブクラスの実?依存します?
180 * これは、PreparedQuery で使用する引数を?列でセ?するも?です?
181 * select * from emp where deptno = ? and job = ? などの PreparedQuery の
182 * ? 部??引数?
183 * ?にセ?して?ます?
184 * ※ こ?クラスでは実?れて?せん?
185 *
186 * @og.rev 4.0.0.0 (2005/01/31) 引数をすべて受け取って実行するメソ?を標準メソ?として追?
187 *
188 * @param names カラ?(CSV形?
189 * @param dbArrayType アレイタイプ名称
190 * @param sysArg DBSysArg配?
191 * @param userArg DBUserArg配?
192 */
193 public void execute( final String names,final String dbArrayType,
194 final DBSysArg[] sysArg,final DBUserArg[] userArg ) {
195 String errMsg = "こ?クラスでは実?れて?せん。execute( String,String,DBSysArg[],DBUserArg[] )";
196 throw new UnsupportedOperationException( errMsg );
197 }
198
199 /**
200 * 引数配?付?クエリーを実行します?
201 * 処??体?, #execute() と同様に、各サブクラスの実?依存します?
202 * これは、PreparedQuery で使用する引数を?列でセ?するも?です?
203 * select * from emp where deptno = ? and job = ? などの PreparedQuery の
204 * [カラ?] 部??引数を?DBTableModelから?にセ?して?ます?
205 * ※ こ?クラスでは実?れて?せん?
206 *
207 * @param rowNo 選択された行番号配?(登録する対象?
208 * @param table DBTableModelオブジェク?登録する?ータ)
209 */
210 public void execute( final int[] rowNo, final DBTableModel table ) {
211 String errMsg = "こ?クラスでは実?れて?せん。execute( final int[] rowNo, final DBTableModel table )";
212 throw new UnsupportedOperationException( errMsg );
213 }
214
215 /**
216 * コミットを行います?
217 *
218 * 外部からコネクションが与えられた?合?、何も行いません?
219 *
220 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
221 * @og.rev 3.8.0.8 (2005/10/03) エラーメ?ージの出力?をメ?ージ?Queryに変更します?
222 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?追??
223 *
224 */
225 public void commit() {
226 if( transaction == null ) { return; }
227
228 if( !transaction.commit() ) {
229 transaction.rollback();
230 realClose();
231 String errMsg = "コミットすることが?来ませんでした? + HybsSystem.CR
232 + getStatement() + HybsSystem.CR ;
233 throw new HybsSystemException( errMsg );
234 }
235
236 // if( connection == null ) { return; }
237 // try {
238 // connection.commit();
239 // }
240 // catch( SQLException ex ) {
241 // transaction.rollback(); // 5.1.9.0 (2010/08/01)
242 // realClose();
243 // String errMsg = "コミットすることが?来ませんでした? + HybsSystem.CR
244 // + ex.getMessage() + ":" + ex.getSQLState()
245 // + HybsSystem.CR + getStatement() + HybsSystem.CR ;
246 // throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び?更
247 // }
248 }
249
250 /**
251 * ロールバックを行います?
252 *
253 * 外部からコネクションが与えられた?合?、何も行いません?
254 *
255 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
256 * @og.rev 3.8.0.8 (2005/10/03) エラーメ?ージの出力?をメ?ージ?Queryに変更します?
257 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?追??
258 *
259 */
260 public void rollback() {
261 if( transaction == null ) { return; }
262
263 if( !transaction.rollback() ) {
264 realClose();
265 String errMsg = "ロールバックすることが?来ません? + HybsSystem.CR
266 + getStatement() + HybsSystem.CR ;
267 throw new HybsSystemException( errMsg );
268 }
269
270 // if( connection == null ) { return; }
271 // try {
272 // connection.rollback();
273 // }
274 // catch( SQLException ex ) {
275 // if( transaction != null ) { transaction.rollback(); } // 5.1.9.0 (2010/08/01)
276 // realClose();
277 // String errMsg = "ロールバックすることが?来ません? + HybsSystem.CR
278 // + ex.getMessage() + ":" + ex.getSQLState()
279 // + HybsSystem.CR + getStatement() + HybsSystem.CR ;
280 // throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び?更
281 // }
282 }
283
284 /**
285 * 使用した Statementオブジェクトをクロースし?Connection オブジェクトを
286 * プ?ルに返します?
287 * 主に、正常終?た?合?クローズ処?なります?
288 *
289 * 外部からコネクションが与えられた?合?、何も行いません?
290 *
291 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
292 * @og.rev 3.6.0.4 (2004/10/14) SQLWarning の取?getWarning)をコメントアウトします?
293 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?追??
294 * @og.rev 5.3.8.0 (2011/08/01) Transaction発生?でclose()するため、ここではclose() しな??
295 *
296 */
297 public void close() {
298 // if( transaction != null ) {
299 // transaction.close(); // 正常な場合?クローズ
300 // transaction = null;
301 // }
302
303 // if( connection != null ) {
304 // try {
305 // // 4.0.0 (2005/01/31)
306 // if( rtnCode > ErrorMessage.NG ) {
307 // realClose();
308 // }
309 // }
310 // finally {
311 // ConnectionFactory.close( connection,connID ); // 4.0.0 (2005/01/31)
312 // connection = null;
313 // }
314 // }
315 }
316
317 /**
318 * Connection オブジェクトを実際にクローズ(破?します?
319 * プ?ルからも削除します?
320 * 実行時エラー等が発生したときに、このメソ?を呼び出します?
321 *
322 * 外部からコネクションが与えられた?合?、何も行いません?
323 *
324 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
325 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?追??
326 * @og.rev 5.3.8.0 (2011/08/01) Transaction発生?でclose()するため、ここではclose() しな??
327 *
328 */
329 public void realClose() {
330 // if( transaction != null ) {
331 // transaction.close( true ); // エラーが発生した?合?クローズ
332 // transaction = null;
333 // }
334
335 // if( connection != null ) {
336 // ConnectionFactory.remove( connection,connID );
337 // connection = null;
338 // }
339 }
340
341 /**
342 * クエリーの実行結果件数をセ?します?
343 * 初期値は -1 です?(クエリーが失敗した?合や,CallableStatement の呼び出し等で
344 * 実行件数が?確でな??合?戻り?)?
345 *
346 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
347 *
348 * @param executeCount 実行結果件数
349 */
350 protected void setExecuteCount( final int executeCount ) {
351 this.executeCount = executeCount;
352 }
353
354 /**
355 * クエリーの実行結果を返します?
356 * クエリーが失敗した?合や,CallableStatement の呼び出し等で実行件数が?確でな?
357 * 場合?, -1 が返されます?
358 *
359 * @return 実行結果件数
360 */
361 public int getExecuteCount() {
362 return executeCount;
363 }
364
365 /**
366 * DBTableModel をセ?します?
367 * なお?検索系実行前に setDBTableModel() で??ブルをセ?して?として?
368 * そ?オブジェクト?破?れて、新しい DBTableModel が生成されます?
369 *
370 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
371 *
372 * @param table DBTableModelオブジェク?
373 */
374 protected void setDBTableModel( final DBTableModel table ) {
375 this.table = table;
376 }
377
378 /**
379 * 実行結果の DBTableModel を返します?
380 *
381 * @return DBTableModelオブジェク?
382 */
383 public DBTableModel getDBTableModel() {
384 return table;
385 }
386
387 /**
388 * ??タベ?スの?検索件数を返します?
389 * (初期値:DB_MAX_ROW_COUNT[={@og.value org.opengion.hayabusa.common.SystemData#DB_MAX_ROW_COUNT}])?
390 * ??タベ?ス自体?検索は,?されたSQLの全件を検索しますが,
391 * DBTableModelの??タとして登録する?件数をこの値に設定します?0は無制限です?
392 * サーバ?のメモリ?と応答時間?確保?為です?
393 *
394 * @return ?検索件数
395 */
396 public int getMaxRowCount() {
397 return maxRowCount;
398 }
399
400 /**
401 * ??タベ?スの?検索件数をセ?します?
402 * ??タベ?ス自体?検索は,?されたSQLの全件を検索しますが,
403 * DBTableModelの??タとして登録する?件数をこの値に設定します?
404 * サーバ?のメモリ?と応答時間?確保?為です?
405 * ゼロ、また?、??値を設定すると、無制?Integer.MAX_VALUE)になります?
406 *
407 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
408 * @og.rev 4.0.0.0 (2005/08/31) ゼロ、また?、??値は、無制?Integer.MAX_VALUE)にする?
409 *
410 * @param maxRowCount ?検索件数
411 */
412 public void setMaxRowCount( final int maxRowCount ) {
413 this.maxRowCount = ( maxRowCount > 0 ) ? maxRowCount : Integer.MAX_VALUE ;
414 }
415
416 /**
417 * ??タベ?スの検索スキ??件数を返します?
418 * ??タベ?ス自体?検索は,?されたSQLの全件を検索しますが,
419 * DBTableModelの??タとしては、スキ??件数??登録されません?
420 * サーバ?のメモリ?と応答時間?確保?為です?
421 *
422 * @return ?検索件数
423 */
424 public int getSkipRowCount() {
425 return skipRowCount;
426 }
427
428 /**
429 * ??タベ?スの検索スキ??件数をセ?します?
430 * ??タベ?ス自体?検索は,?されたSQLの全件を検索しますが,
431 * DBTableModelの??タとしては、スキ??件数??登録されません?
432 * サーバ?のメモリ?と応答時間?確保?為です?
433 *
434 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
435 *
436 * @param skipRowCount スキ??件数
437 */
438 public void setSkipRowCount( final int skipRowCount ) {
439 this.skipRowCount = skipRowCount;
440 }
441
442 /**
443 * ??タベ?スの接続?IDをセ?します?
444 * シス?パラメータ ファイルに定義してある ??タベ?ス識別IDによって?
445 * 接続?を?り替えます?
446 * こ?接続?IDを?に,Connection オブジェクトを作?します?
447 *
448 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
449 * @og.rev 5.1.9.0 (2010/08/01) ?
450 *
451 * @param connID 接続?ID
452 */
453 // public void setConnectionID( final String connID ) {
454 // close();
455 // this.connID = connID;
456 // }
457
458 /**
459 * ア????トフラグをセ?します?
460 * これは、Query で更新処?? SQL ?実行したときにセ?されます?
461 * 更新処?実行:true / 検索処??み?false をセ?します?
462 * こ?メソ?を呼び出さな??合?、デフォルト:true です?
463 *
464 * @og.rev 2.1.2.3 (2002/12/02) ??タベ?ス更新時に、更新フラグをセ?するように変更
465 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
466 *
467 * @param up ア????トされたかど?[true:更新処?false:検索処?
468 */
469 protected void setUpdateFlag( final boolean up ) {
470 updateFlag = up;
471 }
472
473 /**
474 * ア????トフラグを取得します?
475 * これは、Query で更新処?? SQL ?実行したときに true にセ?されます?
476 * 更新処?実行:true / 検索処??み?false を取得できます?
477 *
478 * @og.rev 2.1.2.3 (2002/12/02) ??タベ?ス更新時に、更新フラグをセ?するように変更
479 * @og.rev 4.0.0.0 (2007/07/20) メソ?名変更( getUpdateFlag() ?isUpdate() )
480 *
481 * @return ア????トされたかど?[true:更新処?false:検索処?
482 */
483 public boolean isUpdate() {
484 return updateFlag ;
485 }
486
487 /**
488 * リソースマネージャーをセ?します?
489 * これは、??ロケール)に応じ?DBColumn をあらかじめ設定しておく為に
490 * ?です?
491 * リソースマネージャーが設定されて???また?、所定?キーの DBColumn ?
492 * リソースに存在しな??合?、?部で DBColumn オブジェクトを作?します?
493 *
494 * @og.rev 4.0.0.0 (2005/01/31) lang ?ResourceManager へ変更
495 *
496 * @param resource リソースマネージャー
497 */
498 public void setResourceManager( final ResourceManager resource ) {
499 this.resource = resource;
500 }
501
502 /**
503 * アクセスログ取得?為,ApplicationInfoオブジェクトを設定します?
504 *
505 * @og.rev 3.8.7.0 (2006/12/15) 新規追?
506 * @og.rev 5.1.9.0 (2010/08/01) ?
507 *
508 * @param appInfo ApplicationInfo
509 */
510 // public void setApplicationInfo( final ApplicationInfo appInfo ) {
511 // this.appInfo = appInfo;
512 // }
513
514 /**
515 * ?のリソースを?に?コー?を返します?
516 * ?にリソースが登録されて???合?, null を返します?
517 *
518 * @og.rev 5.3.6.0 (2011/06/01) ?
519 *
520 * @return ?コー?
521 */
522 // public String getLang() {
523 // String lang = null;
524 // if( resource != null ) { lang = resource.getLang(); }
525 // return lang;
526 // }
527
528 /**
529 * エラーコー?を取得します?
530 * エラーコー?は、ErrorMessage クラスで規定されて?コードです?
531 *
532 * @return エラーコー?
533 */
534 public int getErrorCode() { return rtnCode; }
535
536 /**
537 * エラーコー?をセ?します?
538 * エラーコー?は、ErrorMessage クラスで規定されて?コードです?
539 *
540 * @param cd エラーコー?
541 */
542 protected void setErrorCode( final int cd ) { rtnCode = cd; }
543
544 /**
545 * エラーメ?ージオブジェク?を取得します?
546 *
547 * @return エラーメ?ージオブジェク?
548 */
549 public ErrorMessage getErrorMessage() { return errMessage; }
550
551 /**
552 * エラーメ?ージオブジェク?をセ?します?
553 *
554 * @param em エラーメ?ージオブジェク?
555 */
556 protected void setErrorMessage( final ErrorMessage em ) { errMessage = em; }
557
558 /**
559 * エ??設定オブジェクトをセ?します?
560 *
561 * @og.rev 5.3.6.0 (2011/06/01) 新規追?
562 *
563 * @param config エ??設定オブジェク?
564 */
565 public void setEditConfig( final DBEditConfig config ) {
566 this.config = config;
567 }
568
569 /**
570 * エ??設定オブジェクトを取得します?
571 *
572 * @og.rev 5.3.6.0 (2011/06/01) 新規追?
573 *
574 * @return エ??設定オブジェク?
575 */
576 protected DBEditConfig getEditConfig() {
577 return config;
578 }
579
580 //////////////////////////////////////////////////////////////////////////
581 //
582 // 継承時にサブクラスから使用するメソ?? protected )
583 //
584 //////////////////////////////////////////////////////////////////////////
585
586 /**
587 * ResultSet ?DBTableModelに割り当てます?
588 *
589 * 毎回,検索毎に,DBTableModel にコピ?するイメージです?
590 * ResulSet 以外?オブジェクトから,DBTableModelを作?する場合?,
591 * こ?メソ?をオーバ?ライドします?
592 *
593 * こ?メソ?は??execute からのみ,呼び出されます?
594 * それ以外から?呼出し?来ません?
595 *
596 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
597 * @og.rev 3.3.3.3 (2003/08/06) カラ??ラベル名を、大?に変換する?
598 * @og.rev 3.8.5.0 (2006/03/02) CLOB カラ?ど?を判定しCLOBの場合?、Clob オブジェクトから文字?を取り?します?
599 * @og.rev 3.8.8.8 (2007/05/11) ROWID対?小数点対?"0.3" ?".3" と表示される対?
600 * @og.rev 4.0.0.0 (2006/01/31) CLOB カラ?ど?を判定しCLOBの場合?、ストリー?ら?を取り?します?
601 * @og.rev 5.3.6.0 (2011/06/01) DBTableModel作?処?DBTableModelUtilに移動?計機?対?
602 *
603 * @param resultSet ResultSetオブジェク?
604 */
605 protected void createTableModel( final ResultSet resultSet ) {
606 try {
607 if( config == null ) {
608 table = DBTableModelUtil.makeDBTable( resultSet, getSkipRowCount(), maxRowCount, resource );
609 }
610 else {
611 table = DBTableModelUtil.makeEditDBTable( resultSet, getSkipRowCount(), maxRowCount, resource, config );
612 }
613
614 setExecuteCount( table.getRowCount() );
615 }
616 catch( SQLException ex ) {
617 realClose();
618 String errMsg = "??ブルモ?を作?できませんでした?;
619 throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び?更
620 }
621 }
622
623 /**
624 * ConnectionFactory.connection( String ); を利用して,Connection
625 * オブジェクトを取り出します?
626 *
627 * コネクションプ?ルが?の場合?、即エラーになります?
628 *
629 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する?
630 * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得?為,ApplicationInfoオブジェクトを設?
631 * @og.rev 5.1.9.0 (2010/08/01) transaction 属?追??
632 *
633 * @return コネクション
634 */
635 protected Connection getConnection() {
636 // if( connection != null ) { return connection; }
637
638 if( connection == null ) {
639 // 5.1.9.0 (2010/08/01) transaction 属?追??
640 if( transaction == null ) {
641 String errMsg = "Transaction をセ?する前に、コネクションを取り?す要求がなされました?
642 + HybsSystem.CR
643 + "connID = [" + connID + "]" ;
644 throw new HybsSystemException( errMsg );
645 }
646 else {
647 connection = transaction.getConnection( connID );
648 }
649 }
650
651 return connection;
652
653 // MissingResourceException exTemp = null;
654 // for( int i=0; i<DB_RETRY_COUNT; i++ ) {
655 // try {
656 // connection = ConnectionFactory.connection( connID,appInfo );
657 // return connection;
658 // }
659 // catch( MissingResourceException ex ) {
660 // try {
661 // exTemp = ex;
662 // Thread.sleep( DB_RETRY_TIME );
663 // }
664 // catch ( InterruptedException ex2) {
665 // LogWriter.log( "InterruptedException:" + ex2.getMessage() );
666 // }
667 // }
668 // }
669 // String errMsg = "コネクションを取り?すことが?来ませんでした?"
670 // + HybsSystem.CR
671 // + "connID = [" + connID + "]" ;
672 // throw new HybsSystemException( errMsg,exTemp );
673 }
674
675 /**
676 * Transactionオブジェクトを外部から設定します?
677 *
678 * 通常は、ConnectionFactory を使用して、?部で Connection を作?しますが?
679 * ??のトランザクション処?実施するには、外部から Transactionオブジェクトを
680 * を与えて、そこから?Connection を取り?す?があります?
681 *
682 * ここでは、?部の connection が存在しな??合に限り、セ?を許可します?
683 *
684 * @og.rev 5.1.9.0 (2010/08/01) 新規追?
685 *
686 * @param connID 接続?ID
687 * @param tran Transactionオブジェク?
688 */
689 public void setTransaction( final String connID , final Transaction tran ) {
690 if( transaction == null ) {
691 transaction = tran;
692 this.connID = connID;
693 }
694 else {
695 String errMsg = "トランザクションは、すでに設定済みです?"
696 + HybsSystem.CR
697 + "connID = [" + connID + "]" ;
698 throw new HybsSystemException( errMsg );
699 }
700 }
701
702 /**
703 * connection オブジェクトから,ワーニング??タを取り?します?
704 *
705 * ワーニング??タは?SQLWarning クラスのオブジェクトに?件貯えられます?
706 * query 実行後に,確認しておく?があります?
707 *
708 * こ?メソ?は??execute からのみ,呼び出されます?
709 * それ以外から?呼出し?来ません?
710 *
711 * @param connection Connection
712 *
713 * @return ワーニング ErrorMessage
714 */
715 // protected ErrorMessage getWarning( final Connection connection ) {
716 // if( connection == null ) { return null; }
717 //
718 // try {
719 // ErrorMessage em = new ErrorMessage();
720 // for( SQLWarning warning = connection.getWarnings();
721 // warning != null ;
722 // warning = warning.getNextWarning() ) {
723 // em.addMessage( 0,ErrorMessage.WARNING,warning.getMessage(),warning.getSQLState() );
724 // }
725 // return em;
726 // }
727 // catch (SQLException ex) {
728 // realClose();
729 // String errMsg = "ワーニングを取り?すことが?来ませんでした?;
730 // errMsg += System.getProperty( "line.separator" );
731 // errMsg += ex.getMessage() + ":" + ex.getSQLState();
732 // throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び?更
733 // }
734 // }
735
736 /**
737 * こ?接続が、PreparedStatement#getParameterMetaData() を使用するかど?を判定します?
738 *
739 * ConnectionFactory#useParameterMetaData(String) の結果を返します?(postgreSQL対?
740 *
741 * @og.rev 5.3.8.0 (2011/08/01) 新規追?
742 *
743 * @return 使用する場合:true / そ??false
744 * @see org.opengion.fukurou.db.ConnectionFactory#useParameterMetaData(String)
745 */
746 protected boolean useParameterMetaData() {
747 return ConnectionFactory.useParameterMetaData( connID );
748 }
749
750 //////////////////////////////////////////////////////////////////////////
751 //
752 // Object クラスのオーバ?ライド部?
753 //
754 //////////////////////////////////////////////////////////////////////////
755
756 /**
757 * オブジェクト?識別子として?最後?クエリーを返します?
758 *
759 * @return ??クエリー
760 */
761 @Override
762 public String toString() {
763 return "LastQuery :[" + getStatement() + "] ";
764 }
765 }