2

I have a file liquibase.properties with below contents

driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
classpath: ./sqljdbc4-2.0.jar
url: jdbc:sqlserver://localhost:1433;databaseName=staticDB
username: sa
password: admin@123
changeLogFile: myChangeLog.xml

I am using the command liquibase update and by this the database changes are getting deployed on staticDB database

I want to pass a dynamic database name along with the liquibase update command so that I can deploy the database changes on multiple database

I have change the url: in properties file like below

url: jdbc:sqlserver://localhost:1433;databaseName=${database}

I have tried using command like

liquibase update -Ddatabase="Liquibase_Param"

But I am not able to execute the liquibase command correctly as I am getting below error

Unexpected error running Liquibase: com.microsoft.sqlserver.jdbc.SQLServerException: The connection string contains a badly formed name or value.

Please let me know How can I pass dynamic database name while running liquibase update command

Eddie
  • 581
  • 3
  • 11
  • 20
  • When you did this, did you use the same name in both places? You example shows the replaceable value as `${dynamicDB}` but you run liquibase with `-Ddatabase=...` I think you should either use `${database}` in the properties file or use `-DdynamicDB=` on the command line. – SteveDonie Oct 08 '19 at 16:21
  • @SteveDonie : Hi Steve I have use `${database}` at both the places in .properties file as well as passing from command line – Eddie Oct 09 '19 at 11:34
  • 2
    I suspect that Liquibase is not doing the property substitution in the properties file then. You can either write your own wrapper script that does the substitution, or else just have two different properties files. You can specify a different property file to use other than the default `liquibase.properties` by using `--defaultsFile=` – SteveDonie Oct 09 '19 at 15:41

0 Answers0