There are 2 seperate DB involved and both were phisically 2 different places. In my application, I used spring batch and implemented like this:
1.Fetching all ids from AS/400 database(Master DB) 2.comparing with MY SQL db (my application) ids and what ever Ids existed in sql db, I am updating those IDS information to My local DB(MY SQL). Disadvantage : Assume AS400 DB has 10 ids and in my Application has only 2 ids, but in order to get this data I am actually reading all 10 Ids. so waste of time and lack of efficiency right?!
Here is the code I am using in spring batch to fetch data :
<bean id="patternsItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="sql" value="SELECT
J3PATT AS patternId,
J3PTYP AS patternType,
J3CLAS AS PatternClass,
J3REPT AS repeat,
j3CLRS AS numOfColors,
JOENTT AS event,
J3ACT AS activity
FROM TEST006966.JQP030H a WHERE rrn(a) >=( select max(rrn(b)) from
TEST006966.JQP030H b where a.j3patt = b. j3patt) and j3sts = 'N' ORDER BY
J3PATT, JODATE desc ,jotime desc
"/>
<property name="rowMapper">
<bean class="org.springframework.jdbc.core.BeanPropertyRowMapper">
<property name="mappedClass" value="com.mohawkind.batch.patterns.PatternsRowMapper"/>
</bean>
</property>
<property name="dataSource" ref="AS400DataSource" />
</bean>
<bean id="patternsItemWriter" class="com.mohawkind.batch.patterns.PatternsWritter" />
What I am looking for :
I want a solution to only fetch data what is existed in my local(SQL DB). is it possible to connecting 2 db and fetching data through spring batch jobs??
Any ideas,suggestions will greatly appreciated. Thanks in advance..
您无法使用此查询创建数据库视图吗?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.