Using JDBC URL in Liquibase
A JDBC URL is a database connection URL that identifies a database so that the appropriate driver recognizes it and connects to it. Liquibase requires a JDBC driver to establish a connection between Liquibase and your database.
All JDBC URLs begin with jdbc:
. The format of other string elements depends on the JDBC driver. In most cases, the format of the database connection URL resembles the following example:
jdbc:<database>://<host>:<port>/<database_name>;<URL_attributes>
database name | Name of the database to which you want to connect. Can also be the file system path to the database. |
URL attributes | Supported attributes of the database connection URL, such as upgrade=true and create=true . |
host | Name or address of the machine on which the server is running. |
port | Port number that the server framework uses. |
To use the JDBC URL, complete one of the following tasks:
-
Run the
--url
parameter in the CLI:
--url=jdbc:<database>://<host>:<port>/<database_name>;<URL_attributes>
-
Configure
LIQUIBASE_COMMAND_URL
as an environment variable to set it once and pass connection information to Liquibase and your database. Environment variables are only available in Liquibase Pro.
LIQUIBASE_COMMAND_URL =jdbc:<database>://<host>:<port>/<database_name>;<URL_attributes>
-
In the Liquibase properties file, specify a value for
liquibase.command.url
to set it once and pass connection information to Liquibase and your database.
url: jdbc:<database>://<host>:<port>/<database_name>;<URL_attributes>
Note: Command-line arguments override environment variables and the Liquibase properties file data. Environment variables override the properties file data. The properties file does not override any values.
For a list of JDBC examples for different databases, see Liquibase Database Tutorials.