Class H2ConnectionConfiguration.Builder
java.lang.Object
io.r2dbc.h2.H2ConnectionConfiguration.Builder
- Enclosing class:
H2ConnectionConfiguration
A builder for
H2ConnectionConfiguration instances.
This class is not threadsafe
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns a configuredH2ConnectionConfiguration.Configure a file-based database, e.g.Configure an in-memory database, e.g.Configure an option that is appended at the end, e.g.password(CharSequence password) Configure the password.property(H2ConnectionOption option, String value) Configure a property for H2 using pre-buildH2ConnectionOption.Configure a property for H2.Configure a TCP connection to a remote databaseConfigure a TCP connection to a remote database.toString()Configure the database url.Configure the username.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Returns a configuredH2ConnectionConfiguration.- Returns:
- a configured
H2ConnectionConfiguration
-
file
Configure a file-based database, e.g.~/my-databaseor/path/to/my/database.db.- Parameters:
path- of the database file (automatically prefixed withfile:)- Returns:
- this
H2ConnectionConfiguration.Builder
-
inMemory
Configure an in-memory database, e.g.my-test-database.A in-memory database is shut down if the last connection gets closed. To avoid this behavior, configure either the
H2ConnectionOption.DB_CLOSE_DELAYoption throughproperty(H2ConnectionOption, String)or use theH2ConnectionFactory.inMemory(String)connection factory to close the in-memory database by closingCloseableConnectionFactoryexternally.- Parameters:
name- of a private, in-memory database (automatically prefixed withmem:)- Returns:
- this
H2ConnectionConfiguration.Builder
-
tcp
Configure a TCP connection to a remote database.- Parameters:
host- - hostname of the remote database (can belocalhost)path- - path of the database, e.g.~/testresolves to {user.home}/test.db- Returns:
- this
H2ConnectionConfiguration.Builder
-
tcp
Configure a TCP connection to a remote database- Parameters:
host- - hostname of the remote database (can belocalhost)port- - port the database is serving frompath- - path of the database, e.g.~/testresolves to {user.home}/test.db- Returns:
- this
H2ConnectionConfiguration.Builder
-
option
Configure an option that is appended at the end, e.g.DB_CLOSE_DELAY=10, prefixed with ";".- Parameters:
option- to append at the end using a;prefix.- Returns:
- this
H2ConnectionConfiguration.Builder
-
property
Configure a property for H2.- Parameters:
option- the option key.value- the option value.- Returns:
- this
H2ConnectionConfiguration.Builder
-
property
Configure a property for H2 using pre-buildH2ConnectionOption.- Parameters:
option- the option key enumvalue- the option value- Returns:
- this
H2ConnectionConfiguration.Builder
-
password
Configure the password.- Parameters:
password- the password- Returns:
- this
H2ConnectionConfiguration.Builder
-
toString
-
url
Configure the database url. Includes everything after thejdbc:h2:prefix. For in-memory and file-based databases, must include the proper prefix (e.g.file:ormem:).See https://www.h2database.com/html/features.html#database_url for more details.
- Parameters:
url- the url- Returns:
- this
H2ConnectionConfiguration.Builder - Throws:
NullPointerException- ifurlisnull
-
username
Configure the username.- Parameters:
username- the username- Returns:
- this
H2ConnectionConfiguration.Builder
-