Question

I need to create project in which there are two databases local and remote. Remote database needs to be synchronized daily with local database reflecting changes made in local database. I am using JAVA. Database is ORACLE. I have JAVA/JPA code that does CRUD operations on local database. How to synchronize changes to remote database.

Was it helpful?

Solution

I would not do this in Java, but look for native Oracle database synchronization mechanisms/tools. This will

  • be quicker to implement
  • be more robust
  • have faster replication events
  • be more 'correct'

OTHER TIPS

Please look at some synchronization products. SQL Anywhere from Sybase where I work is one such product. You may be able to get a developer/evaluation copy that you can use to explore your options. I am sure Oracle has something similar too.

The basic idea is to be able to track the changes that have happened in the central database. This is typically done by keeping a timestamp for each row. During the synchronization, the remote database provides the last sync time and the server sends to it all rows that have changed since then. Note that the rows that have been deleted in the central database will need some special handling to ensure they get deleted from the remote database.

A true two-way synchronization is lot more complex. You need to also upload the changes from remote database to central and also some conflict resolution strategies have to be implemented for the cases when the same row has been changed in both the remote and central database in incompatible way in the two.

The general problem is too complex to be explained in a respone here but I hope I have been able to provide some useful pointers.

The problem is that what you are asking can range from moderately difficult (for a simple, not very robust system) to a very complex product that could keep a small team busy for a year depending on requirements.

That's why the other answers said "Find another way" (basically)

If you have to do this for a class assignment or something, it's possible but it probably won't be quick, robust or easy.

You need server software on each side, a way to translate unknown tables to data that can be transferred over the wire (along with enough meta-data to re-create it on the other side) and you'll probably want to track database changes (perhaps with a flag or timestamp) so that you don't have to send each record over every time.

It's a hard enough problem that we can't really help much. If I HAD to do that for a customer, I'd quote him at least a man year of work to get it even moderately reliable.

Good Luck

Oracle has a sophistication replication functionality to synchronise databases. Find out more..

From your comments it appears you're using the Oracle Lite: this supports replication, which is covered in the Lite documentation.

Never worked with it, but http://symmetricds.codehaus.org/ might be of use

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top