JDBCCallableStatementReaderPattern
이 패턴은 스토어드 프로시저를 사용하여 JDBC(Java™ Database Connectivity) 연결에서 데이터를 처리하는 비즈니스 로직을 구현하는 데 사용됩니다. 연결 열기 및 닫기의 관리 태스크는 일괄처리 프레임워크에서 수행됩니다.
클래스 지원
- JDBCCallableStatementReader
JDBC 입력 스트림의 사용 패턴이 조회에서 단일 결과를 검색하면 이 클래스가 참조됩니다. 모든 단계 반복 후 조회와 결과가 버려집니다. 준비된 명령문 대신 호출 가능한 명령문을 사용한다는 점에서 이 클래스는 JDBCReader와 다릅니다.
- LocalJDBCCallableStatementReader
데이터가 로컬 데이터베이스에서 읽히면 이 클래스가 참조됩니다.
필수 특성
다음 특성은 패턴에 필요합니다.
특성 | 값 | JDBCCallableStatementReader | LocalJDBCCallableStatementReader |
---|---|---|---|
PATTERN_IMPL_CLASS | JDBCCallableStatementReaderPattern 인터페이스를 구현하는 클래스. | 적용 가능 | 적용 가능 |
ds_jndi_name | 데이터 소스 JNDI 이름. | 적용 가능 | 적용 가능 |
jdbc_url | JDBC URL. 예를 들어, jdbc:derby:C:\\mysample\\CREDITREPORT입니다. | 적용 불가능 | 적용 가능 |
jdbc_driver | JDBC 드라이버. 예를 들어, org.apache.derby.jdbc.EmbeddedDriver입니다. | 적용 불가능 | 적용 가능 |
userid | 데이터베이스의 사용자 ID. | 적용 불가능 | 적용 가능 |
pswd | 사용자 비밀번호. | 적용 불가능 | 적용 가능 |
선택적 특성
다음 특성은 패턴에 대해 선택사항입니다.
특성 이름 | 값 | 설명 | JDBCCallableStatementReader | LocalJDBCCallableStatementReader |
---|---|---|---|---|
CursorHoldabilityEnabled | true 또는 false(기본값은 false) | 이 BDS 리더에 대한 커서 홀드 기능을 사용합니다. | 적용 가능 | 적용 가능 |
디버그 | true 또는 false. 기본값은 false입니다. | 이 일괄처리 데이터 스트림에 대한 자세한 추적을 사용으로 설정합니다. | 적용 가능 | 적용 가능 |
EnablePerformanceMeasurement | true 또는 false. 기본값은 false입니다. | GenericXDBatchStep을 사용 중인 경우, 일괄처리 데이터 스트림과 processRecord 메소드에서 소요된 전체 시간을 계산합니다. | 적용 가능 | 적용 가능 |
EnableDetailedPerformanceMeasurement | true 또는 false. 기본값은 false입니다. | 일괄처리 데이터 스트림의 각 메소드에서 소요된 시간의 자세한 추가 분석을 제공합니다. | 적용 가능 | 적용 가능 |
인터페이스 정의
public interface JDBCCallableStatementReaderPattern {
/**
* 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 ResultSet used by the stream to retrieve all relevant
* data that would be processed part of the job steps.
*/
public ResultSet getResultSet(CallableStatement cstmt) throws SQLException ;
/**
* This method should return a Callable statement that will be used during setup of the
* stream to retrieve all relevant data that would be processed as part of the job steps.
* @return object to be used during process step.
*/
public CallableStatement getInitialCallableStatement(Connection con);
/**
* This method gets called during Job Restart. The restart token should be used to create
* a Callable Statement 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 CallableStatement getRestartCallableStatement(Connection con,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();
}
JDBCCallableStatementReader xJCL 예
<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="IMPLCLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/>
<prop name="ds_jndi_name" value="jdbc/echojndi"/>
<prop name="debug" value="false"/>
<prop name="EnablePerformanceMeasurement" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.JDBCCallableStatementReader</impl-class>
</bds>
</batch-data-streams>