开发者

Making a connection between multiple databases

开发者 https://www.devze.com 2022-12-21 10:11 出处:网络
I\'m using JAVA DB (derby) I want to import a public view of my data to another database (also in java db).

I'm using JAVA DB (derby)

I want to import a public view of my data to another database (also in java db).

I want to pass this data and save in to the other database. I'm having trouble since the general rule is one connec开发者_运维知识库tion to one database.

Help would be much appreciated.


You need two connections, one to each database.

If you want the two operations to be a single unit of work, you should use XA JDBC drivers so you can do two-phase commit. You'll also need a JTA transaction manager.

This is easy to do with Spring.

SELECT from one connection; INSERT into the other. Just standard JDBC is what I'm thinking. You'll want to batch your INSERTs and checkpoint them if you have a lot of rows so you don't build up a huge rollback segment.

I'd wonder why you have to duplicate data this way. "Don't Repeat Yourself" would be a good argument against it. Why do you think you need it in two places like this?

0

精彩评论

暂无评论...
验证码 换一张
取 消