Solved

Comparing recordsets in java

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exchange, squid, proxy, linux 6 83
Restored mailboxes and OST 11 61
Session in java desktop 5 34
Windows 10 and multi programs open freezing 6 54
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

738 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