Skip to content

Commit ea2b87f

Browse files
authored
Update database section of ref guide (spring-attic#5082)
See spring-attic#5079
1 parent 019dc47 commit ea2b87f

File tree

3 files changed

+83
-83
lines changed

3 files changed

+83
-83
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
[[configuration-database-overview]]
3+
A relational database is used to store stream and task definitions as well as the state of executed tasks.
4+
Spring Cloud Data Flow provides schemas for *MariaDB*, *MySQL*, *Oracle*, *PostgreSQL*, *Db2*, *SQL Server*, and *H2*. The schema is automatically created when the server starts.
5+
6+
NOTE: The JDBC drivers for *MariaDB*, *MySQL* (via the _MariaDB_ driver), *PostgreSQL*, *SQL Server* are available without additional configuration. To use any other database you need to put the corresponding JDBC driver jar on the classpath of the server as described <<#add-custom-driver,here>>.
7+
8+
To configure a database the following properties must be set:
9+
10+
* `spring.datasource.url`
11+
* `spring.datasource.username`
12+
* `spring.datasource.password`
13+
* `spring.datasource.driver-class-name`
14+
15+
The `username` and `password` are the same regardless of the database. However, the `url` and `driver-class-name` vary per database as follows.
16+
17+
[frame="none"]
18+
[cols="a,a,a,a"]
19+
[cols="10%,30%,20%,10%"]
20+
|===
21+
|[.small]#Database#|[.small]#spring.datasource.url#|[.small]#spring.datasource.driver-class-name#|[.small]#Driver included#
22+
23+
|[.small]#MariaDB 10.4+#
24+
|[.small]#jdbc:mariadb://${db-hostname}:${db-port}/${db-name}#
25+
|[.small]#org.mariadb.jdbc.Driver#
26+
|[.small]#Yes#
27+
28+
|[.small]#MySQL 5.7#
29+
|[.small]#jdbc:mysql://${db-hostname}:${db-port}/${db-name}?permitMysqlScheme#
30+
|[.small]#org.mariadb.jdbc.Driver#
31+
|[.small]#Yes#
32+
33+
|[.small]#MySQL 8.0+#
34+
|[.small]#jdbc:mariadb://${db-hostname}:${db-port}/${db-name}?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&permitMysqlScheme#{empty}footnote:[SSL is disabled in this example, adjust accordingly for your environment and requirements]
35+
|[.small]#org.mariadb.jdbc.Driver#
36+
|[.small]#Yes#
37+
38+
|[.small]#PostgresSQL#
39+
|[.small]#jdbc:postgres://${db-hostname}:${db-port}/${db-name}#
40+
|[.small]#org.postgresql.Driver#
41+
|[.small]#Yes#
42+
43+
|[.small]#SQL Server#
44+
|[.small]#jdbc:sqlserver://${db-hostname}:${db-port};databasename=${db-name}&encrypt=false#
45+
|[.small]#com.microsoft.sqlserver.jdbc.SQLServerDriver#
46+
|[.small]#Yes#
47+
48+
|[.small]#DB2#
49+
|[.small]#jdbc:db2://${db-hostname}:${db-port}/{db-name}#
50+
|[.small]#com.ibm.db2.jcc.DB2Driver#
51+
|[.small]#No#
52+
53+
|[.small]#Oracle#
54+
|[.small]#jdbc:oracle:thin:@${db-hostname}:${db-port}/{db-name}#
55+
|[.small]#oracle.jdbc.OracleDriver#
56+
|[.small]#No#
57+
|===
58+
59+
==== H2
60+
When no other database is configured and the *H2* driver has been added to the server classpath then
61+
Spring Cloud Data Flow uses an embedded instance of the *H2* database as the default.
62+
63+
NOTE: *H2* is good for development purposes but is not recommended for production use nor is it supported as an external mode.
64+
65+
To use *H2* add the `com.h2database:h2:2.1.214` JDBC driver to the classpath and do not configure any other database.

spring-cloud-dataflow-docs/src/main/asciidoc/configuration-kubernetes.adoc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,13 @@ data:
421421
The password is a base64-encoded value.
422422

423423
[[configuration-kubernetes-rdbms]]
424-
=== Database Configuration
424+
=== Database
425425

426-
Spring Cloud Data Flow provides schemas for H2, MariaDB, Oracle, PostgreSQL, DB2, and SQL Server. The appropriate schema is automatically created when the server starts, provided the right database driver and appropriate credentials are in the classpath.
426+
include::configuration-database.adoc[]
427427

428-
The JDBC drivers for MariaDB, PostgreSQL, SQL Server, and embedded H2 are available out of the box.
429-
If you use any other database, you need to put the corresponding JDBC driver jar on the classpath of the server.
428+
==== Database configuration
430429

431-
For instance, if you use MariaDB in addition to a password in the secrets file, you could provide the following properties in the ConfigMap:
430+
When running in Kubernetes, the database properties are typically set in the ConfigMap. For instance, if you use MariaDB in addition to a password in the secrets file, you could provide the following properties in the ConfigMap:
432431

433432

434433
[source,yaml]
@@ -441,13 +440,9 @@ data:
441440
username: root
442441
password: ${mariadb-root-password}
443442
driverClassName: org.mariadb.jdbc.Driver
444-
url: jdbc:mariadb://${MARIADB_SERVICE_HOST}:${MARIADB_SERVICE_PORT}/test
445-
driverClassName: org.mariadb.jdbc.Driver
446443
----
447444

448-
449-
For PostgreSQL, you could use the following configuration:
450-
445+
Similarly, for PostgreSQL you could use the following configuration:
451446

452447
[source,yaml]
453448
----

spring-cloud-dataflow-docs/src/main/asciidoc/configuration-local.adoc

Lines changed: 13 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -29,91 +29,31 @@ The REST `/about` endpoint provides information on the features that have been e
2929
[[configuration-local-rdbms]]
3030
=== Database
3131

32-
A relational database is used to store stream and task definitions as well as the state of executed tasks.
33-
Spring Cloud Data Flow provides schemas for *H2*, *MariaDB*, *Oracle*, *PostgreSQL*, *Db2*, and *SQL Server*. The schema is automatically created when the server starts.
32+
include::configuration-database.adoc[]
3433

35-
By default, Spring Cloud Data Flow offers an embedded instance of the *H2* database (if the H2 JDBC driver jar is found on the classpath).
36-
The *H2* database is good for development purposes but is not recommended for production use.
37-
38-
NOTE: *H2* database is not supported as an external mode.
39-
40-
The JDBC drivers for *MariaDB*, *PostgreSQL*, *SQL Server* are available without additional configuration.
41-
42-
If you are using the embedded *H2* or any other database, then you need to put the corresponding JDBC driver jar on the classpath of the server.
43-
44-
The database properties can be passed as environment variables or command-line arguments to the Data Flow Server.
45-
46-
==== MariaDB
47-
48-
The following example shows how to define a MariaDB database connection with command Line arguments
34+
==== Database configuration
4935

36+
When running locally, the database properties can be passed as environment variables or command-line arguments to the Data Flow Server. For example, to start the server with MariaDB using command line arguments execute the following command:
5037
[source,bash,subs=attributes]
5138
----
5239
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar \
5340
--spring.datasource.url=jdbc:mariadb://localhost:3306/mydb \
54-
--spring.datasource.username=<user> \
55-
--spring.datasource.password=<password> \
41+
--spring.datasource.username=user \
42+
--spring.datasource.password=pass \
5643
--spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
5744
----
58-
59-
==== PostgreSQL
60-
61-
The following example shows how to define a PostgreSQL database connection with command line arguments:
62-
63-
[source,bash,subs=attributes]
64-
----
65-
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar \
66-
--spring.datasource.url=jdbc:postgresql://localhost:5432/mydb \
67-
--spring.datasource.username=<user> \
68-
--spring.datasource.password=<password> \
69-
--spring.datasource.driver-class-name=org.postgresql.Driver
70-
----
71-
72-
==== SQL Server
73-
74-
The following example shows how to define a SQL Server database connection with command line arguments:
75-
76-
[source,bash,subs=attributes]
77-
----
78-
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar \
79-
--spring.datasource.url='jdbc:sqlserver://localhost:1433;databaseName=mydb&encrypt=false' \
80-
--spring.datasource.username=<user> \
81-
--spring.datasource.password=<password> \
82-
--spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
83-
----
84-
85-
==== Db2
86-
87-
The following example shows how to define a Db2 database connection with command line arguments:
88-
45+
Likewise, to start the server with MariaDB using environment variables execute the following command:
8946
[source,bash,subs=attributes]
9047
----
91-
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar \
92-
--spring.datasource.url=jdbc:db2://localhost:50000/mydb \
93-
--spring.datasource.username=<user> \
94-
--spring.datasource.password=<password> \
95-
--spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver
96-
----
97-
98-
NOTE: Due to licensing restrictions we're unable to bundle Db2 driver. You need to add it to
99-
server's classpath yourself.
100-
101-
==== Oracle
102-
103-
The following example shows how to define a Oracle database connection with command line arguments:
48+
SPRING_DATASOURCE_URL=jdbc:mariadb://localhost:3306/mydb
49+
SPRING_DATASOURCE_USERNAME=user
50+
SPRING_DATASOURCE_PASSWORD=pass
51+
SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.mariadb.jdbc.Driver
10452
105-
[source,bash,subs=attributes]
106-
----
107-
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar \
108-
--spring.datasource.url=jdbc:oracle:thin:@localhost:1521/MYDB \
109-
--spring.datasource.username=<user> \
110-
--spring.datasource.password=<password> \
111-
--spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
53+
java -jar spring-cloud-dataflow-server/target/spring-cloud-dataflow-server-{project-version}.jar
11254
----
11355

114-
NOTE: Due to licensing restrictions we're unable to bundle Oracle driver. You need to add it to
115-
server's classpath yourself.
116-
56+
[#add-custom-driver]
11757
==== Adding a Custom JDBC Driver
11858
To add a custom driver for the database (for example, Oracle), you should rebuild the Data Flow Server and add the dependency to the Maven `pom.xml` file.
11959
You need to modify the maven `pom.xml` of `spring-cloud-dataflow-server` module.
@@ -124,7 +64,7 @@ To add a custom JDBC driver dependency for the Spring Cloud Data Flow server:
12464
. Select the tag that corresponds to the version of the server you want to rebuild and clone the github repository.
12565
. Edit the spring-cloud-dataflow-server/pom.xml and, in the `dependencies` section, add the dependency for the database driver required. In the following example , an Oracle driver has been chosen:
12666

127-
[source, xml]
67+
[source,xml]
12868
----
12969
<dependencies>
13070
...

0 commit comments

Comments
 (0)