This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE TB_SOURCE( | |
col1 VARCHAR2(10), | |
col2 VARCHAR2(20), | |
col3 VARCHAR2(20) | |
); | |
CREATE TABLE TB_TARGET( | |
new_col1 VARCHAR2(10), | |
new_col2 VARCHAR2(20), | |
new_col3 VARCHAR2(20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="repositoryDataSource" | |
class="org.apache.commons.dbcp.BasicDataSource" | |
destroy-method="close"> | |
<property name="driverClassName" value="oracle.jdbc.OracleDriver" /> | |
<property name="url" value="jdbc:oracle:thin:@guest01:1521:myora" /> | |
<property name="username" value="scott" /> | |
<property name="password" value="tiger" /> | |
<property name="initialSize" value="2" /> | |
<property name="minIdle" value="2" /> | |
<property name="maxActive" value="10" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<batch:job id="TestJob01" job-repository="jobRepository"> | |
<batch:step id="SimpleStep"> | |
<batch:tasklet transaction-manager="testTransactionManager" allow-start-if-complete="true"> | |
<batch:chunk | |
reader="TestReader" | |
processor="TestProcessor" | |
writer="TestWriter" | |
commit-interval="1" | |
reader-transactional-queue="false" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import org.springframework.jdbc.core.RowMapper; | |
import test.vo.SourceVO; | |
public class TbSourceMapper implements RowMapper<SourceVO> { | |
@Override | |
public SourceVO mapRow(ResultSet rs, int rowNum) throws SQLException { | |
SourceVO vo = new SourceVO(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.batch.item.ItemProcessor; | |
import test.vo.SourceVO; | |
import test.vo.TargetVO; | |
public class TestProcessor implements ItemProcessor<SourceVO, TargetVO> { | |
@Override | |
public TargetVO process(SourceVO item) throws Exception { | |
TargetVO targetVO = new TargetVO(); | |
targetVO.new_col1 = item.col1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SourceVO { | |
public String col1; | |
public String col2; | |
public String col3; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TargetVO { | |
public String new_col1; | |
public String new_col2; | |
public String new_col3; | |
public String getNewCol1() { | |
return this.new_col1; | |
} | |
public String getNewCol2() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="SourceMapper" | |
class="test.rowmapper.TbSourceMapper"/> | |
<bean id="ParameterSetter" class="test.reader.TestParameterSetter"> | |
<property name="param" value="col1-1"/> | |
</bean> | |
<bean id="TestReader" | |
class="org.springframework.batch.item.database.JdbcCursorItemReader" | |
scope="step"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
import org.springframework.jdbc.core.PreparedStatementSetter; | |
public class TestParameterSetter implements PreparedStatementSetter { | |
private String param; | |
public void setParam(String param) { | |
this.param = param; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="SourceMapper" | |
class="test.rowmapper.TbSourceMapper"/> | |
<bean id="ParameterSetter" class="test.reader.TestParameterSetter" scope="step"> | |
<property name="param" value="#{jobParameters['param1']}"/> | |
</bean> | |
<bean id="TestReader" | |
class="org.springframework.batch.item.database.JdbcCursorItemReader" | |
scope="step"> |
OlderNewer