JDBCCallableStatementReaderPattern

此模式用于使用存储过程实现从 Java™ 数据库连接 (JDBC) 连接处理数据的业务逻辑。打开和关闭连接的管理任务由批处理框架执行。

支持类

  1. JDBCCallableStatementReader

    当 JDBC 输入流的使用模式从查询检索单个结果时引用此类。在步骤的每个迭代后废弃查询和结果。此类与 JDBCReader 的不同之处在于它使用了可调用的语句,而不是编译的语句。

  2. LocalJDBCCallableStatementReader

    从本地数据库读取数据时引用此类。

必需属性

以下属性对于该模式是必需的。
表 1. 必需属性. 此表包含每个必需属性及其值,以及是 JDBCCallableStatementReader 类还是 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 数据库的用户标识。 不适用 适用
pswd 用户密码。 不适用 适用

可选属性

以下属性对于该模式是可选的。
表 2. 可选属性. 此表包含每个可选属性及其值和描述,以及是 JDBCCallableStatementReader 类还是 LocalJDBCCallableStatementReader 类适用。
属性名称 值 描述 JDBCCallableStatementReader LocalJDBCCallableStatementReader
CursorHoldabilityEnabled true 或 false(缺省值为 false) 为此 BDS 阅读器启用游标可持有性 适用 适用
debug 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>

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-base-dist&topic=rgrid_btchpttrnjdcsread
文件名:rgrid_btchpttrnjdcsread.html