A relational database is used to store stream and task definitions as well as the state of executed tasks. Spring Cloud Data Flow provides schemas for H2, HSQLDB, MySQL, Oracle, Postgresql, DB2 and SqlServer that will be automatically created when the server starts. Out of the box Spring Cloud Data Flow offers an embedded instance of the H2 database. The H2 database is good for development purposes but is not recommended for production use.
The JDBC drivers for MySQL (via MariaDB driver), HSQLDB, PostgreSQL along with embedded H2 are available out of the box. If you are using any other database, then the corresponding JDBC driver jar needs to be on the classpath of the server.
The database properties can be passed as environment variables or command-line arguments to the Data Flow Server.
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-dataflow-server-local/target/spring-cloud-dataflow-server-local-1.0.0.BUILD-SNAPSHOT.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 &
If you are using PostgreSQL:
java -jar spring-cloud-dataflow-server-local/target/spring-cloud-dataflow-server-local-1.0.0.BUILD-SNAPSHOT.jar \ --spring.datasource.url=jdbc:postgresql:<db-info> \ --spring.datasource.username=<user> \ --spring.datasource.password=<password> \ --spring.datasource.driver-class-name=org.postgresql.Driver &
If you are using HSQLDB:
java -jar spring-cloud-dataflow-server-local/target/spring-cloud-dataflow-server-local-1.0.0.BUILD-SNAPSHOT.jar \ --spring.datasource.url=jdbc:hsqldb:<db-info> \ --spring.datasource.username=SA \ --spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver &
Note | |
---|---|
There is a schema update to the Spring Cloud Data Flow datastore when
upgrading from version |
Note | |
---|---|
If you wish to use an external H2 database instance instead of the one
embedded with Spring Cloud Data Flow set the
|
To add a custom driver for the database, for example Oracle, it is recommended that you rebuild the Data Flow server and add the dependency to the Maven pom.xml
file.
Since there is a Spring Cloud Data Flow Server for each target platform, you will need to modify the appropriate maven pom.xml
for each platform. There are tags in each github repository for each server version.
To add a custom JDBC driver dependency for the local server implementation:
dependencies
section add the dependency for the database driver required. In the sample below, and Oracle driver has been chosen.<dependencies> ... <dependency> <groupId>com.oracle.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>12.2.0.1</version> </dependency> ... </dependencies>
You can also provide default values when rebuilding the server by adding the following properties to the dataflow-server.yml file
For example adding postgres would look something like this:
spring: datasource: url: jdbc:postgresql://localhost:5432/mydb username: myuser password: mypass driver-class-name:org.postgresql.Driver