Update:
I think the problem is in this line, because it returns an empty list when I called changelog.getChangeSets() , so what is wrong, this code?
static liquibase.changelog.DatabaseChangeLog changelog = new DatabaseChangeLog( "src/main/resources/changelog.xml");
Original post:
My goal is to run DDL database commands with an existing list of changes in the Java class. Currently my setup is this:
public class LiquibaseWithJavaCode { //find the location of the existing changelog.xml file static liquibase.changelog.DatabaseChangeLog changelog = new DatabaseChangeLog( "src/main/resources/changelog.xml"); static void executeUpdate1() throws SQLException, LiquibaseException { java.sql.Connection connection = getConnection(); Database database = DatabaseFactory.getInstance() .findCorrectDatabaseImplementation( new JdbcConnection(connection)); Liquibase liquibase = new liquibase.Liquibase(changelog, new ClassLoaderResourceAccessor(), database); liquibase.update(new Contexts(), new LabelExpression()); } public static Connection getConnection() throws SQLException { Connection conn = null; Properties connectionProps = new Properties(); connectionProps.put("user", "liquibase"); connectionProps.put("password", "password"); conn = DriverManager .getConnection( "jdbc:sqlserver://111.11.1.1;databaseName=liquibase;SelectMethod=cursor", connectionProps); return conn; } } public static void main(String[] args) throws SQLException, LiquibaseException { executeUpdate1(); }
When I run it, it displays here: 
I created changelog.xml and contains many changes that process many DDL commands. But it seems that changeLogFile contains no changes, it is empty. I double-checked with the database, and in fact this table was not actually created, only two tables DATABASECHANGELOG and DATABASECHANGELOGLOCK .
Did I do something wrong? How to fix it? Honestly, I am not familiar with this, so please advice.
source share