Biswajit
Biswajit

Reputation: 2506

How to generate change log file in liquibase using Java

I want to generate a change log XML file in liquibase using Java, which stores the information of two databases difference.

My code is:

Database database=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/test", "root", "admin", "com.mysql.jdbc.Driver", "", null,false,false,null,null,null,null);

        Database database2=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/pizzashop", "root", "admin", "com.mysql.jdbc.Driver", "", null,false,false,null,null,null,null);
      CommandLineUtils.doDiffToChangeLog("changelog.xml", database2, database,new DiffOutputControl(),null,null);

But it generates a blank changelog.xml file.

Upvotes: 2

Views: 3428

Answers (1)

Biswajit
Biswajit

Reputation: 2506

I solved my question.use liquibase 2.0.3 version.

Code is:

Database database=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/lportal", "root", "admin", "com.mysql.jdbc.Driver", 
                null,null,null);

        Database database2=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/llportal", "root", "admin", "com.mysql.jdbc.Driver",
                null,null,null);
    CommandLineUtils.doDiffToChangeLog("changeLogFile.xml",database, database2)

;

Upvotes: 1

Related Questions