Solved

Comparing recordsets in java

Posted on 2011-03-03
5
538 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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

776 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