• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Regarding a batch process design

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi EveryBody
I am new to design though working in java for 2 years.
I have to write a batch process to synchronize two tables.
Simple solution is to make a class and read data from both tables and compare.
Another solution i thougt is to have a seperate classes for table1,table2.Populate the classes with data in constructor.
Write another class which uses the above classes to compare.
Please suggest me whether i am approacingh in proper way.
Regards
Deepa
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most of the classes you need for DB work come from JDBC. If the two tables are in one database instance, you can just do the appropriate queries and wind up with two ResultSet objects to compare. I've done the same table in two database instances before, and built a little wrapper to hold the connection and execute a query for one database. Then I just make one instances of my class for each database. See if this kind of thing makes sense:

What kind of comparison do you have to do? There is a common algorithm for comparing two sorted lists to detect rows on db1 only or db2 only or matching keys and different data, etc. If that sounds like your problem I can post more.
 
Deepa Natrajan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James
Thanks for the reply.
Yes i am looking for the similar thing only.
I need to compate a table in localDB(TABLE L) with a table in globalDB(TABLE M) and update localDB if there is any new entris or change in values found in globalDB.
Thanks and Regards
Deepa
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not that it's my place to do this, but might I suggest that the kind of row-by-row comparison you're suggesting here is a REALLY BAD IDEA. Not only is it terribly wasteful of resource, but it's horrendously slow! There are database tools for doing this that are much more efficient -- they are based on the idea of taking the transaction log from one database and re-executing it on the second database.
Before you try doing this in Java, involve your DBA's and see if they don't already have a synchronization tool for this. If not, it's probably a good idea to invest in one.
Kyle
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic