18. Database configuration

Spring Cloud Skipper uses a relational database to store metadata. We use Flyway to bootstrap and then migrate the database as the product evolves. We currently provide schemas for the following databases: H2, HSQLDB, MySQL, PostgreSQL, Microsoft SQL Server, Oracle 12, and IBM DB2.

The JDBC drivers for MySQL (through the MariaDB driver), HSQLDB, PostgreSQL, and SQL Server, along the embedded H2 database, are bundled with the server jar. If you use any other database, the corresponding JDBC driver jar needs to be on the classpath of the server. If not specified, the server starts with the embedded in-memory H2 database.

The database properties can be passed as environment variables or command-line arguments to the Server.

[Note]Note

Make sure that you configure the correct flyway.schemas for DB2 and SQL Server. Otherwise, Flyway tries to create its schema_version table on the default schema for a connection, which could be different than the schema with which your credentials are associated. See the Flyway documentation for more options.

The following listings show some examples:

export spring_datasource_url=jdbc:postgresql://localhost:5432/mydb
export spring_datasource_username=myuser
export spring_datasource_password=mypass
export spring_datasource_driver-class-name="org.postgresql.Driver"
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:mysql:<db-info> \
    --spring.datasource.username=<user> \
    --spring.datasource.password=<password> \
    --spring.datasource.driver-class-name=org.mariadb.jdbc.Driver &
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:postgresql:<db-info> \
    --spring.datasource.username=<user> \
    --spring.datasource.password=<password> \
    --spring.datasource.driver-class-name=org.postgresql.Driver &
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:hsqldb:mem:<db-info> \
    --spring.datasource.username=sa \
    --spring.datasource.password= \
    --spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver &
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:sqlserver://<db-info>;database=<database-name> \
    --spring.datasource.username=<user> \
    --spring.datasource.password=<password> \
    --flyway.schemas=<database-name> \
    --spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver &
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:oracle:thin:<user>/<password>@<db-address>/<service-id> \
    --spring.datasource.username=<user> \
    --spring.datasource.password=<password> \
    --spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver &
java -jar spring-cloud-skipper-server-{project-version}.jar \
    --spring.datasource.url=jdbc:db2:thin://<db-info>/<db-name> \
    --spring.datasource.username=<user> \
    --spring.datasource.password=<password> \
    --flyway.schemas=<db-name> \
    --spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver &