So I know that you can do an INSERT/SELECT in a single statement. So something like:
However, I'm not sure how that would work using
JDBC except for the fact that with MYSQL if the databases are on the same server and share the same credentials, it would work. Not sure about other databases though.
Aside from that, you'll probably just have to do your select and then batch the results. And it isn't going to be fast.