Database Connections

Use the following options to pass Liquibase the parameters that are required to establish a connection with a database:

  • Connection profiles
  • Command-line arguments
  • Environment variables

The following sections describe these options in more detail.

Connection Profiles

If you use the Liquibase Properties file to specify properties that you do not want to enter as command-line parameters, create a connection profile by specifying values for the following properties:

  • changelog-file – Path to the changelog file
  • liquibase.command.url – JDBC connection string

When you run a Liquibase command from within the project directory, actions are performed on the database specified by the profile properties.

If you intend to run Liquibase diff commands between two databases, specify values for the following properties, as well:

  • referenceUrl – JDBC connection string for reference database
  • referenceUsername – User name for reference database
  • referencePassword – Password for reference database

Although connection profiles allow for the inclusion of user names and passwords, Liquibase recommends that you choose one of the following alternatives to manage authentication properties:

  • Store them in a secure credential repository
  • Enter them when running a command through the CLI

For more information about connection profiles and the Liquibase Properties file, see Specifying Properties in a Connection Profile.

Command-line Arguments

If the Liquibase Properties file does not contain a valid connection profile, or if you need to override the configured properties, use the command prompt to pass connection properties to Liquibase as command-line arguments.

For example, the following command passes authentication credentials and deploys changes to the database identified by the specified properties:

liquibase –changelog-file=dbchangelog.xml --url=jdbc:oracle:thin:@localhost:1521:oracle --username=jay --password=tiger update

For more information about connection properties and other Liquibase parameters, see Command Parameters.

Environment Variables

Liquibase Pro also provides environment variables that pass sensitive data securely during automated processes.

The following examples pass values for a user name, password, changelog file name, and JDBC driver URL, respectively:

  • export LIQUIBASE_COMMAND_USERNAME=dbuser
  • export LIQUIBASE_COMMAND_PASSWORD=letmein
  • export LIQUIBASE_COMMAND_CHANGELOG_FILE=example_changelog.sql
  • export LIQUIBASE_COMMAND_URL=jdbc:h2:tcp://localhost:9090/mem:dev

For more information about Liquibase environment variables, see Liquibase Environment Variables. For more information about the Liquibase parameters to which they correspond, see Command Parameters.