title: liquibase - how to generate the sql script from the changelog after comparing two databases using java?
body: <p>I compared two databases with liquibase java API 3.3.2, then generated the changelog.xml file. Now, I want to generate the sql script that will update the target database.
  here is my code:</p>
  
  <pre><code>Database database;
  Database database2;
  try {
      database = CommandLineUtils.createDatabaseObject(org.postgresql.Driver.class.getClassLoader(), "jdbc:postgresql://localhost:5432/loan", "postgres", "", "org.postgresql.Driver", null, null, false, false, null, null, null, null, null);
      database2=CommandLineUtils.createDatabaseObject(org.postgresql.Driver.class.getClassLoader(), "jdbc:postgresql://localhost:5432/loan2", "postgres", "", "org.postgresql.Driver", null, null, false, false, null, null, null, null, null);
      Liquibase liquibase = new Liquibase("", new FileSystemResourceAccessor(), database);
      DiffResult result = liquibase.diff(database, database2, new CompareControl());
      DiffToChangeLog diffLog = new DiffToChangeLog(result, new DiffOutputControl());
      diffLog.print(System.out);
      //new DiffToReport(result, System.out).print();
  
  } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  </code></pre>
  
  <p><strong>EDIT</strong>
  Here is how I did it, thanks to Steve donie : </p>
  
  <pre><code>        Database database;
      Database database2;
      try {
          database = CommandLineUtils.createDatabaseObject(org.postgresql.Driver.class.getClassLoader(), "jdbc:postgresql://localhost:5432/loan", "postgres", "", "org.postgresql.Driver", null, null, false, false, null, null, null, null, null);
          database2= CommandLineUtils.createDatabaseObject(org.postgresql.Driver.class.getClassLoader(), "jdbc:postgresql://localhost:5432/loan2", "postgres", "", "org.postgresql.Driver", null, null, false, false, null, null, null, null, null);
  
          // generate the changelog that contains the differences
          CommandLineUtils.doDiffToChangeLog("changelog.xml", database, database2, new DiffOutputControl(), null, null);
  
          // generate the sql script from the changeLog (without executing it)
          File sql = new File("output.sql");
          Liquibase liquibase = new Liquibase("changelog.xml", new FileSystemResourceAccessor(), database);
          liquibase.update("Update", new FileWriter(sql));
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>