• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparing two tables of different database

 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two databases (may be different like MySQL and Oracle OR same Oracle as both DB) as DB1 and DB2. I want to compare a table from both the database. In other words,I want to compare DB1.Table1 and DB2.Table1.
I am thinking of two ideas

  • JDBC Connection : In this I will open two connection (One with MySQL and another with Oracle)and compare all the rows from both of the database.
  • Hibernate : I can also achieve this by comparing objects from both the databases.


  • Can anyone explain me what can be the right way to do it, first one, second one or any other way to do it?

    Thanks in advance !
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There are lots of database diffing tools out there, one of these might save you the effort of writing your own.

    If you do want to roll your own, plain old JDBC is probably a better choice. ORMs are not really designed for large scale bulk operations. However, writing something that compares both data and data model is quite a lot of work.
     
    Fidel Edwards
    Ranch Hand
    Posts: 234
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Paul for instant response!

    Paul Sturrock wrote:There are lots of database diffing tools out there, one of these might save you the effort of writing your own.

    Can't go with any of the tool as it is the requirement for only one table.

    Paul Sturrock wrote:
    If you do want to roll your own, plain old JDBC is probably a better choice. ORMs are not really designed for large scale bulk operations.

    Since table will contain only 250 odd records at maximum, I can anguish with it. In case of JDBC, I'm creating two connections, selecting data from the both the database and preparing the object . But issue here is the right way to compare objects, when I want to compare the records of all the 20 columns of the table.
    a) Comparator : will contain 20 getters comparisons
    b) toString: will contain prepared list of getters like


    And we will be comparing the objects only like




    what will be the right approach?
     
    srinivas akarapu
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Edward,

    Where you able to find the best way to compare the data from 2 different tables of 2 different databases? If so, can you please let me know how you have done it?





    Thanks
    Srini
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic