문제

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 connection 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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top