public static final class PostgresqlConnectionConfiguration.Builder extends Object
PostgresqlConnectionConfiguration instances.
This class is not threadsafe
| Modifier and Type | Method and Description |
|---|---|
PostgresqlConnectionConfiguration.Builder |
addHost(String host)
Add host with default port to the hosts list.
|
PostgresqlConnectionConfiguration.Builder |
addHost(String host,
int port)
Add host to the hosts list.
|
PostgresqlConnectionConfiguration.Builder |
applicationName(String applicationName)
Configure the application name.
|
PostgresqlConnectionConfiguration.Builder |
autodetectExtensions(boolean autodetectExtensions)
Configures whether to use
ServiceLoader to discover and register extensions. |
PostgresqlConnectionConfiguration |
build()
Returns a configured
PostgresqlConnectionConfiguration. |
PostgresqlConnectionConfiguration.Builder |
codecRegistrar(CodecRegistrar codecRegistrar)
Register a
CodecRegistrar that can contribute extension Codecs. |
PostgresqlConnectionConfiguration.Builder |
compatibilityMode(boolean compatibilityMode)
Enables protocol compatibility mode for cursored query execution.
|
PostgresqlConnectionConfiguration.Builder |
connectTimeout(Duration connectTimeout)
Configure the connection timeout.
|
PostgresqlConnectionConfiguration.Builder |
database(String database)
Configure the database.
|
PostgresqlConnectionConfiguration.Builder |
enableSsl()
Enable SSL usage.
|
PostgresqlConnectionConfiguration.Builder |
errorResponseLogLevel(io.r2dbc.postgresql.util.LogLevel errorResponseLogLevel)
Configure the
LogLevel for error responses that are part of a statement execution. |
PostgresqlConnectionConfiguration.Builder |
extendWith(Extension extension)
Registers a
Extension to extend driver functionality. |
PostgresqlConnectionConfiguration.Builder |
fetchSize(int fetchSize)
Set the default number of rows to return when fetching results from a query.
|
PostgresqlConnectionConfiguration.Builder |
fetchSize(ToIntFunction<String> fetchSizeFunction)
Set a function that maps a SQL query to the number of rows to return when fetching results for that query.
|
PostgresqlConnectionConfiguration.Builder |
forceBinary(boolean forceBinary)
Force binary results (Binary Transfer).
|
PostgresqlConnectionConfiguration.Builder |
host(String host)
Configure the host.
|
PostgresqlConnectionConfiguration.Builder |
hostRecheckTime(Duration hostRecheckTime)
Controls how long the knowledge about a host state is cached connection factory.
|
PostgresqlConnectionConfiguration.Builder |
loadBalanceHosts(boolean loadBalanceHosts)
In default mode (disabled) hosts are connected in the given order.
|
PostgresqlConnectionConfiguration.Builder |
lockWaitTimeout(Duration lockWaitTimeout)
Configure the Lock wait timeout.
|
PostgresqlConnectionConfiguration.Builder |
loopResources(reactor.netty.resources.LoopResources loopResources)
Configure
LoopResources. |
PostgresqlConnectionConfiguration.Builder |
noticeLogLevel(io.r2dbc.postgresql.util.LogLevel noticeLogLevel)
Configure the
LogLevel for notice responses. |
PostgresqlConnectionConfiguration.Builder |
options(Map<String,String> options)
Configure connection initialization parameters.
|
PostgresqlConnectionConfiguration.Builder |
password(CharSequence password)
Configure the password.
|
PostgresqlConnectionConfiguration.Builder |
password(Publisher<CharSequence> password)
Configure the password publisher.
|
PostgresqlConnectionConfiguration.Builder |
password(Supplier<CharSequence> password)
Configure the password supplier.
|
PostgresqlConnectionConfiguration.Builder |
port(int port)
Configure the port.
|
PostgresqlConnectionConfiguration.Builder |
preferAttachedBuffers(boolean preferAttachedBuffers)
Configure whether
codecs should prefer attached data buffers. |
PostgresqlConnectionConfiguration.Builder |
preparedStatementCacheQueries(int preparedStatementCacheQueries)
Configure the preparedStatementCacheQueries.
|
PostgresqlConnectionConfiguration.Builder |
schema(String schema)
Configure the schema.
|
PostgresqlConnectionConfiguration.Builder |
socket(String socket)
Configure the unix domain socket to connect to.
|
PostgresqlConnectionConfiguration.Builder |
sslCert(String sslCert)
Configure ssl cert for client certificate authentication.
|
PostgresqlConnectionConfiguration.Builder |
sslCert(URL sslCert)
Configure ssl cert for client certificate authentication.
|
PostgresqlConnectionConfiguration.Builder |
sslContextBuilderCustomizer(Function<io.netty.handler.ssl.SslContextBuilder,io.netty.handler.ssl.SslContextBuilder> sslContextBuilderCustomizer)
Configure a
SslContextBuilder customizer. |
PostgresqlConnectionConfiguration.Builder |
sslEngineCustomizer(Function<SSLEngine,SSLEngine> sslEngineCustomizer)
Configure a
SSLEngine customizer. |
PostgresqlConnectionConfiguration.Builder |
sslHostnameVerifier(HostnameVerifier sslHostnameVerifier)
Configure ssl HostnameVerifier.
|
PostgresqlConnectionConfiguration.Builder |
sslKey(String sslKey)
Configure ssl key for client certificate authentication.
|
PostgresqlConnectionConfiguration.Builder |
sslKey(URL sslKey)
Configure ssl key for client certificate authentication.
|
PostgresqlConnectionConfiguration.Builder |
sslMode(io.r2dbc.postgresql.client.SSLMode sslMode)
Configure ssl mode.
|
PostgresqlConnectionConfiguration.Builder |
sslParameters(Function<SocketAddress,SSLParameters> sslParametersFactory)
Configure a
SSLParameters provider for a given SocketAddress. |
PostgresqlConnectionConfiguration.Builder |
sslPassword(CharSequence sslPassword)
Configure ssl password.
|
PostgresqlConnectionConfiguration.Builder |
sslRootCert(String sslRootCert)
Configure ssl root cert for server certificate validation.
|
PostgresqlConnectionConfiguration.Builder |
sslRootCert(URL sslRootCert)
Configure ssl root cert for server certificate validation.
|
PostgresqlConnectionConfiguration.Builder |
sslSni(boolean sslSni)
Configure whether to indicate the hostname and port via SNI to the server.
|
PostgresqlConnectionConfiguration.Builder |
statementTimeout(Duration statementTimeout)
Configure the Statement timeout.
|
PostgresqlConnectionConfiguration.Builder |
targetServerType(MultiHostConnectionStrategy.TargetServerType targetServerType)
Allows opening connections to only servers with required state.
|
PostgresqlConnectionConfiguration.Builder |
tcpKeepAlive(boolean enabled)
Configure TCP KeepAlive.
|
PostgresqlConnectionConfiguration.Builder |
tcpNoDelay(boolean enabled)
Configure TCP NoDelay.
|
PostgresqlConnectionConfiguration.Builder |
timeZone(String timeZone)
Configure the session timezone.
|
PostgresqlConnectionConfiguration.Builder |
timeZone(TimeZone timeZone)
Configure the session timezone.
|
String |
toString() |
PostgresqlConnectionConfiguration.Builder |
username(Publisher<String> username)
Configure the username publisher.
|
PostgresqlConnectionConfiguration.Builder |
username(String username)
Configure the username.
|
PostgresqlConnectionConfiguration.Builder |
username(Supplier<String> username)
Configure the username supplier.
|
public PostgresqlConnectionConfiguration.Builder applicationName(String applicationName)
postgresql-r2dbc.applicationName - the application namePostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if applicationName is nullpublic PostgresqlConnectionConfiguration.Builder autodetectExtensions(boolean autodetectExtensions)
ServiceLoader to discover and register extensions. Defaults to true.autodetectExtensions - to discover and register extensionsPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration build()
PostgresqlConnectionConfiguration.PostgresqlConnectionConfigurationpublic PostgresqlConnectionConfiguration.Builder compatibilityMode(boolean compatibilityMode)
Execute+Sync
messages instead of Execute+Flush. The default mode uses optimized fetching which does not work with newer pgpool versions.compatibilityMode - whether to enable compatibility modePostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder connectTimeout(@Nullable Duration connectTimeout)
connectTimeout - the connection timeoutPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder codecRegistrar(CodecRegistrar codecRegistrar)
CodecRegistrar that can contribute extension Codecs.
Calling this method adds a CodecRegistrar and does not replace existing Extensions.codecRegistrar - registrar to contribute codecsPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder database(@Nullable String database)
database - the databasePostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder enableSsl()
PostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder extendWith(Extension extension)
Extension to extend driver functionality.
Calling this method adds a Extension and does not replace existing Extensions.extension - extension to extend driver functionalityPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder errorResponseLogLevel(io.r2dbc.postgresql.util.LogLevel errorResponseLogLevel)
LogLevel for error responses that are part of a statement execution.errorResponseLogLevel - the log level to use.PostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder fetchSize(int fetchSize)
fetchSize - the number of rows to fetchBuilderIllegalArgumentException - if fetchSize is negativepublic PostgresqlConnectionConfiguration.Builder fetchSize(ToIntFunction<String> fetchSizeFunction)
fetchSizeFunction - a function that maps the number of rows to fetchBuilderIllegalArgumentException - if fetchSizeFunction is nullpublic PostgresqlConnectionConfiguration.Builder forceBinary(boolean forceBinary)
forceBinary - whether to force binary transferPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder host(String host)
host - the hostPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if host is nullIllegalStateException - if addHost(java.lang.String), targetServerType(MultiHostConnectionStrategy.TargetServerType) or hostRecheckTime(Duration) was configured earlier
to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder addHost(String host)
host - the hostPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if host is nullIllegalStateException - if port(int), host(String) or socket(String) was configured earlier to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder addHost(String host, int port)
host - the hostport - the portPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if host is nullIllegalStateException - if port(int), host(String) or socket(String) was configured earlier to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder hostRecheckTime(Duration hostRecheckTime)
10 seconds. Calling this method prepares multi-node configuration. This
method can be only used if the builder was not configured with a single-host configuration.hostRecheckTime - host recheck timePostgresqlConnectionConfiguration.BuilderIllegalStateException - if port(int), host(String) or socket(String) was configured earlier to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder loadBalanceHosts(boolean loadBalanceHosts)
loadBalanceHosts - is load balance mode enabledPostgresqlConnectionConfiguration.BuilderIllegalStateException - if port(int), host(String) or socket(String) was configured earlier to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder lockWaitTimeout(Duration lockWaitTimeout)
This parameter is applied once after creating a new connection.
If lockTimeout is already set using options(Map), it will be overridden.
Lock Timeout
lockWaitTimeout - the lock timeoutPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder loopResources(reactor.netty.resources.LoopResources loopResources)
LoopResources.loopResources - the LoopResourcesPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder noticeLogLevel(io.r2dbc.postgresql.util.LogLevel noticeLogLevel)
LogLevel for notice responses.noticeLogLevel - the log level to use.PostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder options(Map<String,String> options)
These parameters are applied once after creating a new connection. This is useful for setting up client-specific runtime parameters like statement timeouts, time zones etc.
options - the optionsPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if options or any key or value of options is nullpublic PostgresqlConnectionConfiguration.Builder password(@Nullable CharSequence password)
password - the passwordPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder password(Publisher<CharSequence> password)
password - the passwordPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder password(Supplier<CharSequence> password)
password - the passwordPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder port(int port)
5432. Calling this method prepares single-node configuration. This method can be only used if the builder was not configured with a multi-host
configuration.port - the portPostgresqlConnectionConfiguration.BuilderIllegalStateException - if addHost(java.lang.String), targetServerType(MultiHostConnectionStrategy.TargetServerType) or hostRecheckTime(Duration) was configured earlier to
ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder preferAttachedBuffers(boolean preferAttachedBuffers)
codecs should prefer attached data buffers. The default is false, meaning that codecs will copy data from the input buffer into a byte[]
or similar data structure that is enabled for garbage collection. Using attached buffers is more efficient but comes with the requirement that decoded values (such as Json) must
be consumed to release attached buffers to avoid memory leaks.preferAttachedBuffers - the flag whether to prefer attached buffersPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder preparedStatementCacheQueries(int preparedStatementCacheQueries)
-1, meaning there's no limit. The value of 0 disables the cache. Any other value specifies the cache size.preparedStatementCacheQueries - the preparedStatementCacheQueriesPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder schema(@Nullable String schema)
schema - the schemaPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder socket(String socket)
socket - the socket pathPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if socket is nullIllegalStateException - if addHost(java.lang.String), targetServerType(MultiHostConnectionStrategy.TargetServerType) or hostRecheckTime(Duration) was configured earlier
to ensure a consistent configuration statepublic PostgresqlConnectionConfiguration.Builder sslContextBuilderCustomizer(Function<io.netty.handler.ssl.SslContextBuilder,io.netty.handler.ssl.SslContextBuilder> sslContextBuilderCustomizer)
SslContextBuilder customizer. The customizer gets applied on each SSL connection attempt to allow for just-in-time configuration updates. The Function gets
called with the prepared SslContextBuilder that has all configuration options applied. The customizer may return the same builder or return a new builder instance to be used to
build the SSL context.sslContextBuilderCustomizer - customizer functionPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if sslContextBuilderCustomizer is nullpublic PostgresqlConnectionConfiguration.Builder sslEngineCustomizer(Function<SSLEngine,SSLEngine> sslEngineCustomizer)
SSLEngine customizer. The customizer gets applied on each SSL connection attempt to allow for just-in-time configuration updates. The Function gets
called with a SSLEngine instance that has all configuration options applied. The customizer may return the same builder or return a new builder instance to be used to
build the SSL context.sslEngineCustomizer - customizer functionPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if sslEngineCustomizer is nullpublic PostgresqlConnectionConfiguration.Builder sslParameters(Function<SocketAddress,SSLParameters> sslParametersFactory)
SSLParameters provider for a given SocketAddress. The provider gets applied on each SSL connection attempt to allow for just-in-time configuration updates.
Typically used to configure SSL protocolssslParametersFactory - customizer functionPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if sslParametersFactory is nullpublic PostgresqlConnectionConfiguration.Builder sslSni(boolean sslSni)
sslSni - whether to indicate the hostname and port via SNI. Sets SSLParameters.setServerNames(List) on the SSLParameters instance provided by
sslParameters(Function).PostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslCert(String sslCert)
sslCert - an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslCert(URL sslCert)
sslCert - an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslHostnameVerifier(HostnameVerifier sslHostnameVerifier)
sslHostnameVerifier - HostnameVerifierPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslKey(String sslKey)
sslKey - a PKCS#8 private key file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslKey(URL sslKey)
sslKey - a PKCS#8 private key file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslMode(io.r2dbc.postgresql.client.SSLMode sslMode)
sslMode - the SSL mode to use.PostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslPassword(@Nullable CharSequence sslPassword)
sslPassword - the password of the sslKey, or null if it's not password-protectedPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslRootCert(String sslRootCert)
sslRootCert - an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder sslRootCert(URL sslRootCert)
sslRootCert - an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder statementTimeout(Duration statementTimeout)
This parameter is applied once after creating a new connection.
If statementTimeout is already set using options(Map), it will be overridden.
Statement Timeout
statementTimeout - the statement timeoutPostgresqlConnectionConfiguration.Builderpublic PostgresqlConnectionConfiguration.Builder targetServerType(MultiHostConnectionStrategy.TargetServerType targetServerType)
MultiHostConnectionStrategy.TargetServerType.PREFER_SECONDARY tries to connect to a secondary if any are available, otherwise allows falls back to a primary.
Default value is MultiHostConnectionStrategy.TargetServerType.ANY.targetServerType - target server typePostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if targetServerType is nullpublic PostgresqlConnectionConfiguration.Builder tcpKeepAlive(boolean enabled)
enabled - whether to enable TCP KeepAlivePostgresqlConnectionConfiguration.BuilderSocket.setKeepAlive(boolean)public PostgresqlConnectionConfiguration.Builder tcpNoDelay(boolean enabled)
enabled - whether to enable TCP NoDelayPostgresqlConnectionConfiguration.BuilderSocket.setTcpNoDelay(boolean)public PostgresqlConnectionConfiguration.Builder timeZone(String timeZone)
timeZone - the timeZone identifierPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if timeZone is empty or nullTimeZone.getTimeZone(String)public PostgresqlConnectionConfiguration.Builder timeZone(TimeZone timeZone)
timeZone - the timeZone identifierPostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if timeZone is nullTimeZone.getTimeZone(String)public PostgresqlConnectionConfiguration.Builder username(String username)
username - the usernamePostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if username is nullpublic PostgresqlConnectionConfiguration.Builder username(Publisher<String> username)
username - the usernamePostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if username is nullpublic PostgresqlConnectionConfiguration.Builder username(Supplier<String> username)
username - the usernamePostgresqlConnectionConfiguration.BuilderIllegalArgumentException - if username is nullCopyright © 2024. All rights reserved.