public static final class MySqlConnectionConfiguration.Builder extends Object
MySqlConnectionConfiguration creation.| Modifier and Type | Method and Description |
|---|---|
MySqlConnectionConfiguration.Builder |
autodetectExtensions(boolean enabled)
Configures whether to use
ServiceLoader to discover and register extensions. |
MySqlConnectionConfiguration |
build()
Builds an immutable
MySqlConnectionConfiguration with current options. |
MySqlConnectionConfiguration.Builder |
connectTimeout(@Nullable Duration connectTimeout)
Configure the connection timeout.
|
MySqlConnectionConfiguration.Builder |
database(@Nullable String database)
Configure the database.
|
MySqlConnectionConfiguration.Builder |
extendWith(Extension extension)
Registers a
Extension to extend driver functionality and manually. |
MySqlConnectionConfiguration.Builder |
host(String host)
Configure the host.
|
MySqlConnectionConfiguration.Builder |
password(@Nullable CharSequence password)
Configure the password, MySQL allows to login without password.
|
MySqlConnectionConfiguration.Builder |
passwordPublisher(Publisher<String> passwordPublisher)
Registers a password publisher function.
|
MySqlConnectionConfiguration.Builder |
port(int port)
Configure the port.
|
MySqlConnectionConfiguration.Builder |
prepareCacheSize(int prepareCacheSize)
Configures the maximum size of the server-preparing cache.
|
MySqlConnectionConfiguration.Builder |
queryCacheSize(int queryCacheSize)
Configures the maximum size of the
Query parsing cache. |
MySqlConnectionConfiguration.Builder |
serverZoneId(@Nullable ZoneId serverZoneId)
Enforce the time zone of server.
|
MySqlConnectionConfiguration.Builder |
socketTimeout(@Nullable Duration socketTimeout)
Deprecated.
This option has been deprecated as of version 1.0.1, because it has no effect and
serves no purpose.
|
MySqlConnectionConfiguration.Builder |
sslCa(@Nullable String sslCa)
Configure SSL root certification for server certificate validation.
|
MySqlConnectionConfiguration.Builder |
sslCert(@Nullable String sslCert)
Configure client SSL certificate for client authentication.
|
MySqlConnectionConfiguration.Builder |
sslContextBuilderCustomizer(Function<io.netty.handler.ssl.SslContextBuilder,io.netty.handler.ssl.SslContextBuilder> customizer)
Configure a
SslContextBuilder customizer. |
MySqlConnectionConfiguration.Builder |
sslHostnameVerifier(HostnameVerifier sslHostnameVerifier)
Configure SSL
HostnameVerifier, it is available only set sslMode(SslMode) as
SslMode.VERIFY_IDENTITY. |
MySqlConnectionConfiguration.Builder |
sslKey(@Nullable String sslKey)
Configure client SSL key for client authentication.
|
MySqlConnectionConfiguration.Builder |
sslKeyPassword(@Nullable CharSequence sslKeyPassword)
Configure the password of SSL key file for client certificate authentication.
|
MySqlConnectionConfiguration.Builder |
sslMode(SslMode sslMode)
Configure ssl mode.
|
MySqlConnectionConfiguration.Builder |
tcpKeepAlive(boolean enabled)
Configure TCP KeepAlive.
|
MySqlConnectionConfiguration.Builder |
tcpNoDelay(boolean enabled)
Configure TCP NoDelay.
|
MySqlConnectionConfiguration.Builder |
tlsVersion(String... tlsVersion)
Configure TLS versions, see
TlsVersions. |
MySqlConnectionConfiguration.Builder |
unixSocket(String unixSocket)
Configure the Unix Domain Socket to connect to.
|
MySqlConnectionConfiguration.Builder |
useClientPrepareStatement()
Configure the protocol of parametrized statements to the text protocol.
|
MySqlConnectionConfiguration.Builder |
user(String user)
Set the user for login the database.
|
MySqlConnectionConfiguration.Builder |
username(String user)
An alias of
user(String). |
MySqlConnectionConfiguration.Builder |
useServerPrepareStatement()
Configure the protocol of parametrized statements to the binary protocol.
|
MySqlConnectionConfiguration.Builder |
useServerPrepareStatement(Predicate<String> preferPrepareStatement)
Configure the protocol of parametrized statements and prepare-preferred simple statements to the
binary protocol.
|
MySqlConnectionConfiguration.Builder |
zeroDateOption(ZeroDateOption zeroDate)
Configure the
ZeroDateOption. |
public MySqlConnectionConfiguration build()
MySqlConnectionConfiguration with current options.MySqlConnectionConfiguration.public MySqlConnectionConfiguration.Builder database(@Nullable @Nullable String database)
database - the database, or null if no database want to be login.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder unixSocket(String unixSocket)
unixSocket - the socket file path.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if unixSocket is null.public MySqlConnectionConfiguration.Builder host(String host)
host - the host.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if host is null.public MySqlConnectionConfiguration.Builder password(@Nullable @Nullable CharSequence password)
Note: for memory security, should not use intern String for password.
password - the password, or null when user has no password.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder port(int port)
3306.port - the port.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if the port is negative or bigger than 65535.public MySqlConnectionConfiguration.Builder connectTimeout(@Nullable @Nullable Duration connectTimeout)
connectTimeout - the connection timeout, or null if has no timeout.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder socketTimeout(@Nullable @Nullable Duration socketTimeout)
socketTimeout property in the
JDBC driver. In fact, SO_TIMEOUT has effect only for OIO socket transport. Default no
timeout.socketTimeout - the socket timeout, or null if has no timeout.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder user(String user)
user - the user.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if user is null.public MySqlConnectionConfiguration.Builder username(String user)
user(String).user - the user.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if user is null.public MySqlConnectionConfiguration.Builder serverZoneId(@Nullable @Nullable ZoneId serverZoneId)
serverZoneId - the ZoneId, or null if query in initialization.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder zeroDateOption(ZeroDateOption zeroDate)
ZeroDateOption. It is a behavior option when this driver receives a value of
zero-date.zeroDate - the ZeroDateOption.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if zeroDate is null.public MySqlConnectionConfiguration.Builder sslMode(SslMode sslMode)
SslMode.sslMode - the SSL mode to use.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if sslMode is null.public MySqlConnectionConfiguration.Builder tlsVersion(String... tlsVersion)
TlsVersions.tlsVersion - TLS versions.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if the array tlsVersion is null.public MySqlConnectionConfiguration.Builder sslHostnameVerifier(HostnameVerifier sslHostnameVerifier)
HostnameVerifier, it is available only set sslMode(SslMode) as
SslMode.VERIFY_IDENTITY. It is useful when server was using special Certificates or need
special verification.
Default is builtin HostnameVerifier which use RFC standards.
sslHostnameVerifier - the custom HostnameVerifier.MySqlConnectionConfiguration.BuilderIllegalArgumentException - if sslHostnameVerifier is nullpublic MySqlConnectionConfiguration.Builder sslCa(@Nullable @Nullable String sslCa)
sslMode(SslMode) is configured for verify server certification.
Default is null, which means that the default algorithm is used for the trust manager.
sslCa - an X.509 certificate chain file in PEM format.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder sslCert(@Nullable @Nullable String sslCert)
sslCert - an X.509 certificate chain file in PEM format, or null if no SSL cert.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder sslKey(@Nullable @Nullable String sslKey)
sslKey - a PKCS#8 private key file in PEM format, or null if no SSL key.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder sslKeyPassword(@Nullable @Nullable CharSequence sslKeyPassword)
sslKeyPassword - the password of the sslKey, or null if it's not
password-protected.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder sslContextBuilderCustomizer(Function<io.netty.handler.ssl.SslContextBuilder,io.netty.handler.ssl.SslContextBuilder> customizer)
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.customizer - customizer functionMySqlConnectionConfiguration.BuilderIllegalArgumentException - if customizer is nullpublic MySqlConnectionConfiguration.Builder tcpKeepAlive(boolean enabled)
enabled - whether to enable TCP KeepAliveMySqlConnectionConfiguration.BuilderSocket.setKeepAlive(boolean)public MySqlConnectionConfiguration.Builder tcpNoDelay(boolean enabled)
enabled - whether to enable TCP NoDelayMySqlConnectionConfiguration.BuilderSocket.setTcpNoDelay(boolean)public MySqlConnectionConfiguration.Builder useClientPrepareStatement()
The text protocol is default protocol that's using client-preparing. See also MySQL documentations.
MySqlConnectionConfiguration.Builderpublic MySqlConnectionConfiguration.Builder useServerPrepareStatement()
The binary protocol is compact protocol that's using server-preparing. See also MySQL documentations.
MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder useServerPrepareStatement(Predicate<String> preferPrepareStatement)
The preferPrepareStatement configures whether to prefer prepare execution on a
statement-by-statement basis (simple statements). The Predicate accepts the simple SQL
query string and returns a boolean flag indicating preference. true prepare-preferred,
false prefers direct execution (text protocol). Defaults to direct execution.
The binary protocol is compact protocol that's using server-preparing. See also MySQL documentations.
preferPrepareStatement - the above Predicate.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if preferPrepareStatement is null.public MySqlConnectionConfiguration.Builder queryCacheSize(int queryCacheSize)
Query parsing cache. Usually it should be power of two.
Default to 0. Driver will use unbounded cache if size is less than 0.
Notice: the cache is using EL model (the PACELC theorem) which provider better performance. That means it is an elastic cache. So this size is not a hard-limit. It should be over 16 in average.
queryCacheSize - the above size, 0 means no cache, -1 means unbounded cache.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder prepareCacheSize(int prepareCacheSize)
256. Driver will use unbounded cache if size is less than 0. It is used
only if using server-preparing parametrized statements, i.e. the useServerPrepareStatement()
is set.
Notice: the cache is using EC model (the PACELC theorem) for ensure consistency. Consistency is
very important because MySQL contains a hard limit of all server-prepared statements which has been
opened, see also max_prepared_stmt_count. And, the cache is one-to-one connection, which
means it will not work on thread-concurrency.
prepareCacheSize - the above size, 0 means no cache, -1 means unbounded
cache.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder autodetectExtensions(boolean enabled)
ServiceLoader to discover and register extensions. Defaults to
true.enabled - to discover and register extensions.MySqlConnectionConfiguration.Builder.public MySqlConnectionConfiguration.Builder extendWith(Extension extension)
Extension to extend driver functionality and manually.
Notice: the driver will not deduplicate Extensions of autodetect discovered and manually
extended. So if a Extension is registered by this function and autodetect discovered, it
will get two Extension as same.
extension - extension to extend driver functionality.MySqlConnectionConfiguration.Builder.IllegalArgumentException - if extension is null.public MySqlConnectionConfiguration.Builder passwordPublisher(Publisher<String> passwordPublisher)
passwordPublisher - function to retrieve password before making connection.MySqlConnectionConfiguration.Builder.Copyright © 2018–2023 asyncer.io. All rights reserved.