このパターンは、Java Database Connectivity (JDBC) 接続を使用して、データベースからデータを取得する場合に使用されます。
このクラスは、JDBC 入力ストリームの使用パターンが、照会から単一の結果を取得される場合に参照されます。取得された結果はステップの毎回の反復後に使用され、廃棄されます。
このクラスは、データがローカル・データベースから読み取られる場合に参照されます。
プロパティー | 値 | LocalJDBCReader | CursorHoldableJDBCReader | JDBCReader |
---|---|---|---|---|
PATTERN_IMPL_CLASS | JDBCReaderPattern インターフェースを実装するクラス | 適用可 |
適用可 |
適用可 |
ds_jndi_name | データ・ソース JNDI 名 | 適用可 |
該当なし |
適用可 |
jdbc_url | JDBC URL。例) jdbc:derby:C:¥¥mysample¥¥CREDITREPORT | 適用可 |
該当なし |
該当なし |
jdbc_driver | JDBC ドライバー。例えば、org.apache.derby.jdbc.EmbeddedDriver です。 | 適用可 |
該当なし |
該当なし |
userid | データベースのユーザー ID。例) Myid | 適用可 |
該当なし |
該当なし |
pswd | ユーザー・パスワード。例えば、mypwd などです。LocalJDBCReader のみ。 | 適用可 |
該当なし |
該当なし |
プロパティー名 | 値 | 説明 | LocalJDBCReader | CursorHoldableJDCReader | JDBCReader |
---|---|---|---|---|---|
debug |
true または false (デフォルトは false) |
このバッチ・データ・ストリームに対する詳細トレースを使用可能にします。 |
適用可 |
適用可 |
適用可 |
EnablePerformanceMeasurement |
true または false (デフォルトは false) |
GenericXDBatchStep を使用している場合に、バッチ・データ・ストリームおよび processRecord メソッドにかかった合計時間を計算します。 |
適用可 |
適用可 |
適用可 |
EnableDetailedPerformanceMeasurement |
true または false (デフォルトは false) |
バッチ・データ・ストリームの各メソッドにかかった時間の詳細を提供します。 |
適用可 |
適用可 |
適用可 |
public interface JDBCReaderPattern { /** * This method is invoked during the job setup phase. * * @param props properties provided in the xJCL */ public void initialize(Properties props); /** * This method should retrieve values for the various columns for the current row from the given resultset object. * Typically this data would be used to populate an intermediate object which would be returned * @param resultSet * @return */ public Object fetchRecord(ResultSet resultSet); /** * This method should return a SQL query that will be used during setup of the stream to retrieve all relevant * data that would be processed part of the job steps * @return object to be used during process step. */ public String getInitialLookupQuery(); /** * This method gets called during Job Restart. The restart token should be used to create an SQL query that will * retrieve previously unprocessed records. * Typically the restart token would be the primary key in the table and the query would get all rows with * primary key value > restarttoken * @param restartToken * @return The restart query */ public String getRestartQuery(String restartToken); /** * This method gets called just before a checkpoint is taken. * @return The method should return a string value identifying the last record read by the stream. */ public String getRestartTokens(); }
<batch-data-streams> <bds> <logical-name>inputStream</logical-name> <props> <prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/> <prop name="ds_jndi_name" value="jdbc/fvtdb"/> <prop name="debug" value="true"/> <prop name="DEFAULT_APPLICATION_NAME" value="XDCGIVT"/> <!-- versions prior to 6103 only --> </props> <impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.CursorHoldableJDBCReader</impl-class> </bds> </batch-data-streams>
<batch-data-streams> <bds> <logical-name>inputStream</logical-name> <props> <prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/> <prop name="jdbc_url" value="jdbc:derby:C:¥¥mysample¥¥CREDITREPORT"/> <prop name="jdbc_driver" value="org.apache.derby.jdbc.EmbeddedDriver"/> <prop name="user_id" value="myuserid"/> <prop name="pswd" value="mypswd"/> <prop name="debug" value="true"/> </props> <impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCReader</impl-class> </bds> </batch-data-streams>