相关文章推荐
淡定的盒饭  ·  ASP.NET 核心 Blazor ...·  1 月前    · 
傻傻的馒头  ·  STRING_SPLIT ...·  1 月前    · 
犯傻的黄豆  ·  Branches API | GitLab ...·  1 周前    · 
大气的扁豆  ·  Spring Cloud ...·  2 年前    · 
纯真的显示器  ·  php ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
public static void main(String[] args) throws Exception {
    //execute("jdbc:postgresql://localhost:5432/JAVA_Test", "Admin", "123456", "org.postgresql.Driver");
    execute("jdbc:jtds:sqlserver://localhost:5432/Liquibase_JAVA", "sa", "123456!", "net.sourceforge.jtds.jdbc.Driver");
public static void execute(String url, String userName, String password, String driver) throws Exception  {
    DatabaseConnection dbConnection = new DatabaseConnection(url, driver, userName, password);
    Connection conn = dbConnection.getConnection();
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
    String changeLog = "/job_executor/liquibasechangelog/databaseChangeLog.xml";
    Liquibase liquibase = new Liquibase(changeLog, new FileSystemResourceAccessor(), database);
    liquibase.update(null);
    conn.close();

I have my changeLogFile inside my project. It's kind of weird that i'm getting an error changeLogFile.xml does not exists.

Can anyone help me with this, THanks

You reference changeLogFile.xml but in your description, but in your code you're using databaseChangeLog.xml. Are you sure the file with the name in the code exists? – DavidX Jan 26, 2018 at 0:57

Most likely your change log file is not there:

/job_executor/liquibasechangelog/databaseChangeLog.xml

but there:

job_executor/liquibasechangelog/databaseChangeLog.xml

Please notice the / missing in the second path so it will be relative, not absolute.

Did you try to execute cat job_executor/liquibasechangelog/databaseChangeLog.xml from the place where you are executing your java? – Michal Rorat Jan 25, 2018 at 23:30

I have fixed it, by adding the liquibasechangelog folder (where my xml files resides) to the build path and then by referring it just by the file name instead of path to the file name

just like this

String changeLog = "databaseChangeLog.xml";

THanks @DavidX @MichalRorat

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.