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>
  • Specify liquibase.command.url in the liquibase.properties file 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 liquibase.properties file data. The liquibase.properties file does not override any values.

JDBC URL examples

Database URL
Apache Derby jdbc:derby://localhost:1527/yourdatabase;create=true
AWS Redshift

jdbc:redshift://endpoint:5439/yourdatabase

AWS example: jdbc:redshift://yourcluster-identifier.us-east-1.redshift.amazonaws.com:5439/yourdatabase

Cassandra

jdbc:cassandra://localhost:9042/yourKeyspace;DefaultKeyspace=yourKeyspace

Cassandra on DataStax Astra

jdbc:cassandra://localhost:9042;DefaultKeyspace=keyspace;AuthMech=2;UID=username;
PWD=password;SecureConnectionBundlePath=path/to/secure-connect-database_name.zip;TunableConsistency=6

For more information, see Using Liquibase with Cassandra on DataStax Astra.

Cloud Spanner jdbc:cloudspanner:/projects/<project>/instances/<instance>/databases/<database>
CockroachDB

CockroachDB on-premises:

jdbc:postgresql://localhost:26257/database?ssl=true&sslmode=require&sslrootcert=
/full-path/certs/ca.crt&sslkey=/full-ath/certs/client.user.key.pk8&sslcert=/full-path/certs/client.user.crt

CockroachDB cloud:

jdbc:postgresql://liquibase-3r8.aws-us-east-2.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=liquibase-ca.crt

For more information, see Using Liquibase with CockroachDB.

DB2 LUW jdbc:db2://localhost:5432/yourdatabase
DB2 on z/OS jdbc:db2://localhost:446/yourdatabase:retrieveMessagesFromServerOnGetMessage=true;
emulateParameterMetaDataForZCalls=1;
Firebird jdbc:firebirdsql://localhost:3050//firebird/data/testdb
Hive jdbc:hive2://localhost:10000/yourdatabase;UID=eselyavka;UseNativeQuery=1
HSQLDB jdbc:hsqldb:hsql://localhost:9001/yourdatabase
Impala jdbc:impala://localhost:21050/yourdatabase
Informix jdbc:informix-sqli://localhost:9088/yourdatabase:INFORMIXSERVER=dbserver
InterBase jdbc:interbase://localhost:3050/interbase/yourdatabase
MariaDB

MariaDB on-premises:

jdbc:mariadb://localhost:3306/yourdatabase

MariaDB cloud:

jdbc:mariadb://endpoint:3306/yourdatabase

AWS example: jdbc:mariadb://myrds.cz1j1vh9uvuo.us-east-1.rds.amazonaws.com:3306/yourdatabase

MaxDB jdbc:sapdb://localhost:7200/yourdatabase
MongoDB jdbc:mongodb://localhost:27017/yourdatabase
MySQL jdbc:mysql://localhost:3306/yourdatabase
Oracle

Oracle on-premises:

jdbc:oracle:thin:@localhost:1521/yourservicename

Oracle cloud:

jdbc:oracle:thin:@endpoint:3306:sid

AWS example: jdbc:oracle:thin:@ yourrds.cz1j1vh9uvuo.us-east-1.rds.amazonaws.com:3306:orcl

Oracle ATP & ADW

jdbc:oracle:thin:@ yourdatabase_high?TNS_ADMIN=/path/to/Wallet_yourdatabasename

For more information, see Using Liquibase with Oracle ATP & ADW.

PostgreSQL

PostgreSQL on-premises:

jdbc:postgresql://localhost:5432/yourdatabase

PostgreSQL cloud:

jdbc:postgresql://instancehost:5432/yourdatabase?user=userName&password=password

AWS example: jdbc:postgresql://yourinstance.123456789012.us-east-1.rds.amazonaws.com:5432
/postgresql?user=user&password=password

SAP HANA jdbc:sap://localhost:30013/?databaseName=yourdatabase&encrypt=true
Snowflake

jdbc:snowflake://account_ID.snowflakecomputing.com/?connection_params

AWS example: jdbc:snowflake://tn12345.us-east-1.snowflakecomputing.com/?db=lbcat&schema=public

For more information, see Using Liquibase with Snowflake.

SQL Server jdbc:sqlserver://localhost:1433/yourdatabase
SQLite jdbc:sqlite:yourdatabase
Sybase Anywhere jdbc:jtds:sybase://localhost:5002/yourdatabase
Sybase Enterprise jdbc:jtds:sybase://localhost:5432/yourdatabase
Teradata jdbc:teradata://localhost/DATABASE=yourdatabase
Vertica jdbc:vertica://localhost:5433/yourdatabase
VoltDB jdbc:voltdb://localhost:21212
YugabyteDB jdbc:postgresql://localhost:5433/yourdatabase

Related links