Announcement Announcement Module
Collapse
No announcement yet.
Doing a batch Select (DB1) to batch Insert (DB2) with Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Doing a batch Select (DB1) to batch Insert (DB2) with Spring

    Hi,

    is there a convenient way to do a batch "select * from product" from a Database 1 and getting doing a batch Insert in DataBase 2 with Spring. I see that the JDBCTemplate return a List with the queryForList() method. The problem here is that the list returned might be too big. I need to transfert 10 million records from DataBase1 to DataBase2.

    The best way, I guess, would be to insert the row from the RecordSet parsing loop.

    Can I use the RowCallbackHandler to do this job?

    I need to do this job :
    Code:
    - resultSet = getTheResultSet("Select * from Product");
    - Start While (looping in ResultSet){
    -- get row from ResultSet...
    -- Insert Row from ResultSet to Row In DataBase2
    -End while.
    -close all jdbc stuff.
    Should I do it in plain jdbc or can I use the Spring framework?


    Thanks.

    Etienne

  • #2
    I don't think there is anything in Spring specifically for this scenario, but you can still use Spring's JDBC templates.

    The best way, I guess, would be to insert the row from the RecordSet parsing loop
    Try submitting the inserts as a batch (Statement.addBatch). You can vary the size to find the optimum batch size.

    You might be interested to follow this thread (which has no replies yet).

    Comment

    Working...
    X