public static final class PostgresqlConnectionConfiguration.Builder extends Object
PostgresqlConnectionConfiguration
instances.
This class is not threadsafe
Modifier and Type | Method and Description |
---|---|
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)
Registers a
CodecRegistrar that can contribute extension Codec s. |
PostgresqlConnectionConfiguration.Builder |
compatibilityMode(boolean compatibilityMode)
Enables protocol compatibility mode for cursored query execution.
|
PostgresqlConnectionConfiguration.Builder |
connectTimeout(Duration connectTimeout)
Configures the connection timeout.
|
PostgresqlConnectionConfiguration.Builder |
database(String database)
Configure the database.
|
PostgresqlConnectionConfiguration.Builder |
enableSsl()
Enable SSL usage.
|
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 |
lockWaitTimeout(Duration lockWaitTimeout)
Configure the Lock wait timeout.
|
PostgresqlConnectionConfiguration.Builder |
loopResources(reactor.netty.resources.LoopResources loopResources)
Configure
LoopResources . |
PostgresqlConnectionConfiguration.Builder |
options(Map<String,String> options)
Configure connection initialization parameters.
|
PostgresqlConnectionConfiguration.Builder |
password(CharSequence password)
Configure the password.
|
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 |
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 |
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 |
statementTimeout(Duration statementTimeout)
Configure the Statement timeout.
|
PostgresqlConnectionConfiguration.Builder |
tcpKeepAlive(boolean enabled)
Configure TCP KeepAlive.
|
PostgresqlConnectionConfiguration.Builder |
tcpNoDelay(boolean enabled)
Configure TCP NoDelay.
|
String |
toString() |
PostgresqlConnectionConfiguration.Builder |
username(String username)
Configure the username.
|
public PostgresqlConnectionConfiguration.Builder applicationName(String applicationName)
postgresql-r2dbc
.applicationName
- the application namePostgresqlConnectionConfiguration.Builder
IllegalArgumentException
- if applicationName
is null
public PostgresqlConnectionConfiguration.Builder autodetectExtensions(boolean autodetectExtensions)
ServiceLoader
to discover and register extensions. Defaults to true.autodetectExtensions
- to discover and register extensionsPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration build()
PostgresqlConnectionConfiguration
.PostgresqlConnectionConfiguration
public 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.Builder
public PostgresqlConnectionConfiguration.Builder connectTimeout(@Nullable Duration connectTimeout)
connectTimeout
- the connection timeoutPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder codecRegistrar(CodecRegistrar codecRegistrar)
CodecRegistrar
that can contribute extension Codec
s.
Calling this method adds a CodecRegistrar
and does not replace existing Extension
s.codecRegistrar
- registrar to contribute codecsPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder database(@Nullable String database)
database
- the databasePostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder enableSsl()
PostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder extendWith(Extension extension)
Extension
to extend driver functionality.
Calling this method adds a Extension
and does not replace existing Extension
s.extension
- extension to extend driver functionalityPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder fetchSize(int fetchSize)
fetchSize
- the number of rows to fetchBuilder
IllegalArgumentException
- if fetchSize
is negativepublic PostgresqlConnectionConfiguration.Builder fetchSize(ToIntFunction<String> fetchSizeFunction)
fetchSizeFunction
- a function that maps the number of rows to fetchBuilder
IllegalArgumentException
- if fetchSizeFunction
is null
public PostgresqlConnectionConfiguration.Builder forceBinary(boolean forceBinary)
forceBinary
- whether to force binary transferPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder host(String host)
host
- the hostPostgresqlConnectionConfiguration.Builder
IllegalArgumentException
- if host
is null
public 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.Builder
public PostgresqlConnectionConfiguration.Builder loopResources(reactor.netty.resources.LoopResources loopResources)
LoopResources
.loopResources
- the LoopResources
PostgresqlConnectionConfiguration.Builder
public 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.Builder
IllegalArgumentException
- if options
or any key or value of options
is null
public PostgresqlConnectionConfiguration.Builder password(@Nullable CharSequence password)
password
- the passwordPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder port(int port)
5432
.port
- the portPostgresqlConnectionConfiguration.Builder
public 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.Builder
public 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.Builder
IllegalArgumentException
- if username
is null
public PostgresqlConnectionConfiguration.Builder schema(@Nullable String schema)
schema
- the schemaPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder socket(String socket)
socket
- the socket pathPostgresqlConnectionConfiguration.Builder
IllegalArgumentException
- if socket
is null
public 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.Builder
IllegalArgumentException
- if sslContextBuilderCustomizer
is null
public PostgresqlConnectionConfiguration.Builder sslCert(String sslCert)
sslCert
- an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslCert(URL sslCert)
sslCert
- an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslHostnameVerifier(HostnameVerifier sslHostnameVerifier)
sslHostnameVerifier
- HostnameVerifier
PostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslKey(String sslKey)
sslKey
- a PKCS#8 private key file in PEM formatPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslKey(URL sslKey)
sslKey
- a PKCS#8 private key file in PEM formatPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslMode(io.r2dbc.postgresql.client.SSLMode sslMode)
sslMode
- the SSL mode to use.PostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslPassword(@Nullable CharSequence sslPassword)
sslPassword
- the password of the sslKey, or null if it's not password-protectedPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslRootCert(String sslRootCert)
sslRootCert
- an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builder
public PostgresqlConnectionConfiguration.Builder sslRootCert(URL sslRootCert)
sslRootCert
- an X.509 certificate chain file in PEM formatPostgresqlConnectionConfiguration.Builder
public 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.Builder
public PostgresqlConnectionConfiguration.Builder tcpKeepAlive(boolean enabled)
enabled
- whether to enable TCP KeepAlivePostgresqlConnectionConfiguration.Builder
Socket.setKeepAlive(boolean)
public PostgresqlConnectionConfiguration.Builder tcpNoDelay(boolean enabled)
enabled
- whether to enable TCP NoDelayPostgresqlConnectionConfiguration.Builder
Socket.setTcpNoDelay(boolean)
public PostgresqlConnectionConfiguration.Builder username(String username)
username
- the usernamePostgresqlConnectionConfiguration.Builder
IllegalArgumentException
- if username
is null
Copyright © 2022. All rights reserved.