Guest User

Untitled

a guest
Dec 21st, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import liquibase.database.Database;
  2. import liquibase.database.DatabaseFactory;
  3. import liquibase.diff.DiffGeneratorFactory;
  4. import liquibase.diff.DiffResult;
  5. import liquibase.diff.compare.CompareControl;
  6. import liquibase.diff.output.DiffOutputControl;
  7. import liquibase.diff.output.changelog.DiffToChangeLog;
  8. import liquibase.resource.ClassLoaderResourceAccessor;
  9. import liquibase.resource.ResourceAccessor;
  10.  
  11. public class DiffDatabase {
  12. public static void main(String[] args) throws Exception {
  13. String userName = "";
  14. String password = "";
  15. String driver = "net.sourceforge.jtds.jdbc.Driver";
  16. String dbUrl = "jdbc:jtds:sqlserver://10.1.1.1/DB";
  17. String refdbUrl = "jdbc:jtds:sqlserver://10.1.1.1/REFDB";
  18. ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
  19. Database db = DatabaseFactory.getInstance().openDatabase(dbUrl, userName, password, driver, null, null, null, resourceAccessor);
  20. Database refdb = DatabaseFactory.getInstance().openDatabase(refdbUrl, userName, password, driver, null, null, null, resourceAccessor);
  21. CompareControl compareControl = new CompareControl();
  22. DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(refdb, db, compareControl);
  23. DiffOutputControl diffOutputControl = new DiffOutputControl().setIncludeCatalog(false).setIncludeSchema(false);
  24. new DiffToChangeLog(diffResult, diffOutputControl).print(System.out);
  25. }
  26. }
Add Comment
Please, Sign In to add comment