我正在尝试制作一个Spring Batch而我没有经验.
是否可以从每个批处理步骤传递信息,或者它们是否必须完全独立?
例如,如果我有
<batch:step id="getSQLs" next="runSQLs">
<batch:tasklet transaction-manager="TransactionManager"
ref="runGetSQLs" />
</batch:step>
<batch:step id="runSQLs">
<batch:tasklet transaction-manager="TransactionManager"
ref="runRunSQLs" />
</batch:step>
Run Code Online (Sandbox Code Playgroud)
并且getSQLs触发一个bean,该bean执行一个类,该类生成一个String类型的List.是否可以引用runSQLs触发的bean列表?("触发"可能不是正确的术语,但我想你知道我的意思)
更新:所以getSQLs步骤触发这个bean:
<bean id="runGetSQLs" class="myTask"
scope="step">
<property name="filePath" value="C:\Users\username\Desktop\sample.txt" />
</bean>
Run Code Online (Sandbox Code Playgroud)
它触发执行此方法的myTask类:
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
ExecutionContext stepContext = this.stepExecution.getExecutionContext();
stepContext.put("theListKey", sourceQueries);
return RepeatStatus.FINISHED;
}
Run Code Online (Sandbox Code Playgroud)
我是否需要以某种方式将stepExecution传递给execute方法?
我使用以下方法获取表中的所有列名:
SELECT COLUMN_NAME
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME='<TABLE_NAME>'
AND OWNER = '<SCHEMA>'
Run Code Online (Sandbox Code Playgroud)
我在不同数据库中的相同表上调用相同的sql语句,但以不同的顺序获取结果.有什么东西我可以附加到我的SQL,以便列将以相同的顺序返回?
是否有一个查询可以用来获取我可以同时使用的会话数量?我正在处理一些数据库连接并收到错误:
ORA-02391: 超出同时 SESSIONS_PER_USER 限制
如何获得此限制的值?
所以假设我有一个迭代字符串列表的for循环.字符串列表就像
List<String> myString = {NEW ROW, cs, 1, 2, 3, NEW ROW, tp, 3, 4, 5}
Run Code Online (Sandbox Code Playgroud)
我希望for循环遍历列表并在每次NEW ROW出现在列表中之后删除NEW ROW和下一个x元素.
我怎样才能做到这一点?
我的尝试:
for (int index = 0; index < myList.size(); index++) {
if (myList.get(index).equals("NEW ROW")) {
for (int j = index; j < index + x; j++) {
myList.remove(j);
}
index = index + x;
}
}
Run Code Online (Sandbox Code Playgroud)
我的尝试不起作用.