I have this requirement that I have been trying to solve for a couple of days now.

I have this source DB. The objective is to extract data from this source DB and insert into a oracle table. The meta data for both tables are the same (1-1 mapping).

Essentially I am trying to do a "insert into <tablename_1> select * from <tablename_2>" through a JDBC connection.

Any ideas?


create a prepared statement for the insert

create a statement (using a different connection) for the select

get a result set

iterate through the result set

for each row from the result set set the parameters on the prepared statement and call addBatch

for every 500 rows or so call executeBatch on the prepared statement

after the last read row call executeBatch on the prepared statement, again

finished (unless autocommit is turned off in which case you need to call commit)