Jim
Jim

Reputation: 13

Comparing sql query resultsets in java

I want to run a query programmatically using java on a sql server database running on our dev environment and production environment and compare the results. would doing a column by column comparison be the best way to compare the resultsets or is there a better way to do it ?

Thank You

Upvotes: 1

Views: 794

Answers (3)

Erkan Haspulat
Erkan Haspulat

Reputation: 12572

If you can do it in the database, do it in the database in a single query. It will be a lot easier to code, and will run a lot more faster.

Upvotes: 1

Rocky Pulley
Rocky Pulley

Reputation: 23321

Another quick test would be to query the data and dump it to a file then do a diff on the two files.

Upvotes: 0

tjg184
tjg184

Reputation: 4686

Comparing resultsets would work. The other option would be to create an object for each resultset and compare that. You could define your equals method to handle this, like any other ordinary Java object.

Much of this will depend on what you want to produce in the end. If all you're only concerned about resultset 1 being different from resultset 2, either method would work.

Upvotes: 2

Related Questions