Running liquibase in java code

I’ve used the following example:

liquibase.properties


Can you try to run the command yourself, please?

Hello,


I’m trying to execute in Java code analogue of Ant’s “updateDatabase” task:

  1. Main.main( new String[]{"--defaultsFile=db/properties/db.test.properties --logLevel=debug update"} );


First, I could not find an updateDatabase command. I’ve tried: update, updateSQL, but all the time I’m getting:

  1. Errors:
  2.   Command not passed


My db.test.properties file if it may help:

  1. #liquibase.properties
  2. driver: org.hsqldb.jdbcDriver
  3. url: jdbc:hsqldb:mem:datasourcedb
  4. username: TEST
  5. password: TEST
  6. changeLogFile: db/changelog/db.changelog-master.xml

What am I doing wrong? Please help.

Not sure if this is the problem  but your properties file should be format of

property_name=property_value  using = instead of :b (colon)

Otherwise it looks correct.  The command line parsing is done and the code doesn’t think it found a ‘command’ but update should work.

I think you’ve asked another question but I will answer this here in case anyone else runs into the same problem.  The command line parameter you passed was seen as a single argument and instead of being broken into separate parameters.  The result of this invocation is that Liquibase sees one parameter

parameter=–defaultsFile=db/properties/db.test.properties --logLevel=debug update

The code then splits the parameter to get the attribute and value:
attribute_name = defaultsFile
value = db/properties/db.test.properties --logLevel=debug update

As a result, Liquibase doesn’t really get the ‘update’ command, it is just part of the value of the defaultsFile string.

Should be something like this:

parms = new String String[]{

                “–defaultsFile=db/properties/db.test.properties”,

                “–logLevel=debug”,

                “update”} ;

(found from your latest post)