Solved

Comparing recordsets in java

Posted on 2011-03-03
5
542 Views
Last Modified: 2012-05-11
I need to compare a few records from 2 different versions of a DB and point out the mismatch if any. What is the best way to do this? Also I need to point out the mismatch in the structure (column name mismatch, additoinal column) of the table if any.
0
Comment
Question by:PearlJamFanatic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 334 total points
ID: 35033752
Well, to compare the table structures you'll probably want to use getMetaData method like shown in this link:

http://www.roseindia.net/jdbc/JdbcGetMetadata.shtml

The comparison of ResultSets startegy would probably very much depend
on the suzes of these ResultSets - and how many mismatches you expect to have.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35033776
If you have rather big tables and really need to caompare them often, I'd consider still
importing one of them into the same database as the other and use
database facilities to compare them, as that will definitel will be more effective.

If you need to do it only once then probably connecting to two databases, making sure
you order your query in the same way  and stepping through ResultSets one by one will
be some kind of the option. The more information you have where you can expect differences, which wouild allow
you to minimize the number of rows you select - the better you are off with the required
resources, times.  Well, it is hard to beleve ther could be one best straeguy in this task for
all different situations you can imagine with respect to sizes of the record sets, type of data, probability of the differences, etc.
If you have effective databases - the less rows you have to select and analyze in
Java code, the more you can do on the server side - the better.


0
 
LVL 47

Expert Comment

by:for_yan
ID: 35033799


here you'll find  two more considerations
http://www.thatsjava.com/java-essentials/11433/

And again they are appropriate to some cases and may not be so good for other situations.
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 334 total points
ID: 35033817
One more thought which occured to me - if those would be
tables on two Oracle databases and tables are big  (I work mostly with Oracle so
it's easier for me to think of Oracle) I would
think it would be more efficient in many cases to make a database link between
the two DB and try to use as much as possible Oracle means to compare
the data using SQL or even PL/SQL, and then only try to do in Java those
comparisons which require to fetch less data but may be more sophisticated
from logical point of view and require more flexibility in output, formatting etc.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
ID: 35034796
There are two different things there:

a. metadata differences
b. data differences

a. only needs to be done once probably. b. might be better done if you make the rowset into a List of beans first
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question