?
Solved

Comparing recordsets in java

Posted on 2011-03-03
5
Medium Priority
?
548 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 1336 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 1336 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 664 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Changing a few Outlook Options can help keep you organized!
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

762 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