File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Sync DataBases Postgre SQL and My sql Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Sync DataBases Postgre SQL and My sql" Watch "Sync DataBases Postgre SQL and My sql" New topic
Author

Sync DataBases Postgre SQL and My sql

Anchit Kalra
Greenhorn

Joined: Jan 25, 2009
Posts: 9
I am writting a program in which I i need to synch two DB's one in Mysql and PostgreSql. So Does any one have any ideas on how to do it.

thanks anchit
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26193
    
  66

Anchit,
What do you mean by "synch"? Replicate? Somehow merge the contents?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anchit Kalra
Greenhorn

Joined: Jan 25, 2009
Posts: 9
I am really sorry, well i already have a database Cars in MySql on which my java gui works. What i need to do is incorporate a second DBMS such that if the first one (mysql) fails I have a backup on PostgresSql. So if a change is made in the My sql DB it should reflect on my POSTGRES SQL too.

So i wante dideas on how to do this....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So you want a hot backup of a different database type? Doing this accross two databases will be difficult; the only way I can thing is by performing every update twice from your application (and ensuring your application is the only one that accesses the database). This will require XA transactions, which is a further overhead.

If your primary and slave databases were of the same type you could probably use out the box tools to do this. Any reason why they are not?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Anchit Kalra
Greenhorn

Joined: Jan 25, 2009
Posts: 9
can i make a Static String array


where the array will hold all the queries which have been fired till now and when the user exits a function can be called which will execute these queries
one by one on my second DataBase in PostgresSQL.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

This approach has a number of problems:
  • what happens if your application crashes? All changes will fail in the second database
  • If you work round this problem by making the whole thing run in a big transaction you will impact the perfomance of your databases and application
  • If you use surrogate keys these values are arbitrary and not guarenteed to follow the same creation algorithm accross databases. So there is no guarentee the same SQL statement will have the same effect on both databases.
  • What happens if something else updates your slave database before your application? Or what happens if two or more users use your applciation at the same time?
  • What happens when the user doesn't exit a function, and instead just wanders away from their PC? How does you application time them out and what happens when it does?


  • Manually writing a hot backup application is non-trivial.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Sync DataBases Postgre SQL and My sql
     
    Similar Threads
    MS. SQL DBA
    SetNull() in a select PreparedStatement
    Does 1Z0-007 cover PL/SQL?
    Database transformation
    good select statement but does not run in java jdbc