Database Comparison Utility
Technology : Java JDBC
This utility is primarily intended to support database migration validation, schema parity checks, and post-migration reconciliation.
- It’s a standalone Java command-line utility that performs a name-level comparison of six categories of database objects between an IBM DB2 source schema and an Azure SQL target database.
- It identifies objects that exist in one system but not the other, making it suitable for migration validation and schema parity checks.
- It connects independently to the DB2 source and Azure SQL target, retrieves the names of supported database objects, and compares their presence across both environments.
- Connection details are shared with the broader project toolset via a single properties file.
Database Object Type Compared
Its compares six categories of database objects:
- Tables
- Views
- Stored Procedures
- Functions
- Triggers
- Sequences
All comparisons are case-insensitive — names are normalized to upper case before matching.
Architecture & Flow
For each object category, the utility identifies:
· Objects present in both DB2 and Azure SQL
· Objects present in DB2 but missing from Azure SQL
· Objects present in Azure SQL but missing from DB2
The comparison is performed at the object-name level. It does not currently validate the internal structure or definition of an object, such as column data types, constraints, index definitions, SQL logic, or procedural code.
Comparison Approach
Get SHAILENDRA UPADHYAY’s stories in your inbox
Join Medium for free to get updates from this writer.
The high-level processing flow is:
Steps.
The class follows a consistent three-step pattern for each object type:
- Fetch from DB2 — executes a SQL query against the relevant DB2 catalogue table, filtered to source schema.
- Fetch from Azure SQL — executes a matching query against the corresponding sys.* view.
- Compare — builds upper-cased sets/maps for both sides, then performs a symmetric difference to find objects present on one side only.
Result Mode
Each comparison produces a typed *CompareResult wrapper object containing:
- A List<*Result> of mismatched objects, each carrying the object name, schema, optional metadata (table name, type), and a status string.
- Integer counts for the total unique object names found on each side.
Status values are exactly two: DB2 ONLY and SQL ONLY
Output
Two files are generated after every run, both timestamped with the run start time:
A rolling log file <className>.log (max 10 MB × 3 rotations) captures every query and count at ALL levels using a plain-text formatter.
Use Cases
This utility can be used at different stages of a database migration:
- Pre-migration baseline: Capture the expected object inventory from the DB2 source.
- Post-migration validation: Compare the migrated Azure SQL database against the DB2 source.
- Schema parity validation: Identify objects that are missing or unexpectedly present.
- Migration troubleshooting: Quickly identify objects that may have failed during schema conversion or deployment.
- Regression validation: Re-run the utility after subsequent migration or deployment activities to verify object-level parity.






