Package io.vertx.mysqlclient
Class MySQLConnectOptions
- java.lang.Object
-
- io.vertx.sqlclient.SqlConnectOptions
-
- io.vertx.mysqlclient.MySQLConnectOptions
-
public class MySQLConnectOptions extends SqlConnectOptions
Connect options for configuringMySQLConnection
orMySQLBuilder
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CHARACTER_ENCODING
static String
DEFAULT_CHARSET
static Map<String,String>
DEFAULT_CONNECTION_ATTRIBUTES
static String
DEFAULT_HOST
static String
DEFAULT_PASSWORD
static int
DEFAULT_PIPELINING_LIMIT
static int
DEFAULT_PORT
static String
DEFAULT_SCHEMA
static SslMode
DEFAULT_SSL_MODE
static boolean
DEFAULT_USE_AFFECTED_ROWS
static String
DEFAULT_USER
-
Fields inherited from class io.vertx.sqlclient.SqlConnectOptions
DEFAULT_CACHE_PREPARED_STATEMENTS, DEFAULT_METRICS_NAME, DEFAULT_PREPARED_STATEMENT_CACHE_FILTER, DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE, DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT, DEFAULT_RECONNECT_ATTEMPTS, DEFAULT_RECONNECT_INTERVAL
-
-
Constructor Summary
Constructors Constructor Description MySQLConnectOptions()
MySQLConnectOptions(JsonObject json)
MySQLConnectOptions(MySQLConnectOptions other)
MySQLConnectOptions(SqlConnectOptions other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MySQLConnectOptions
addProperty(String key, String value)
Add a property for this client, which will be sent to server at the connection start.static MySQLConnectOptions
fromUri(String connectionUri)
Provide aMySQLConnectOptions
configured from a connection URI.MySQLAuthenticationPlugin
getAuthenticationPlugin()
Get the default authentication plugin for connecting the server.String
getCharacterEncoding()
Get the Java charset for encoding string values.String
getCharset()
Get the charset for the connection.String
getCollation()
Get the collation for the connection.int
getPipeliningLimit()
Get the pipelining limit count.String
getServerRsaPublicKeyPath()
Get the path of the server RSA public key.Buffer
getServerRsaPublicKeyValue()
Get the value of the server RSA public key.SocketAddress
getSocketAddress()
SslMode
getSslMode()
Get the value of the configured SSL mode.protected void
init()
Initialize with the default options.boolean
isUseAffectedRows()
Get how affected rows are calculated on update/delete/insert.boolean
isUsingDomainSocket()
MySQLConnectOptions
merge(JsonObject other)
Returns new options created after this object and merged with theother
json config.MySQLConnectOptions
setAuthenticationPlugin(MySQLAuthenticationPlugin authenticationPlugin)
Set the defaultauthentication plguin
for the client, the option will take effect at the connection start.MySQLConnectOptions
setCachePreparedStatements(boolean cachePreparedStatements)
Set whether prepared statements cache should be enabled.MySQLConnectOptions
setCharacterEncoding(String characterEncoding)
Set the Java charset for encoding string values, this value is UTF-8 by default.MySQLConnectOptions
setCharset(String charset)
Set the charset for the connection.MySQLConnectOptions
setCollation(String collation)
Set the collation for the connection.MySQLConnectOptions
setDatabase(String database)
Specify the default database for the connection.MySQLConnectOptions
setHost(String host)
Specify the host for connecting to the server.MySQLConnectOptions
setPassword(String password)
Specify the user password to be used for the authentication.MySQLConnectOptions
setPipeliningLimit(int pipeliningLimit)
Set the pipelining limit count.MySQLConnectOptions
setPort(int port)
Specify the port for connecting to the server.MySQLConnectOptions
setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)
Set the maximum number of prepared statements that the connection will cache.MySQLConnectOptions
setPreparedStatementCacheSqlFilter(java.util.function.Predicate<String> predicate)
Set a predicate filtering prepared statements that the connection will cache.MySQLConnectOptions
setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Set the maximum length of prepared statement SQL string that the connection will cache.MySQLConnectOptions
setProperties(Map<String,String> properties)
Set properties for this client, which will be sent to server at the connection start.MySQLConnectOptions
setReconnectAttempts(int attempts)
Set the value of reconnect attemptsMySQLConnectOptions
setReconnectInterval(long interval)
Set the reconnect intervalMySQLConnectOptions
setServerRsaPublicKeyPath(String serverRsaPublicKeyPath)
Set the path of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.MySQLConnectOptions
setServerRsaPublicKeyValue(Buffer serverRsaPublicKeyValue)
Set the value of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.MySQLConnectOptions
setSslMode(SslMode sslMode)
Set theSslMode
for the client, this option can be used to specify the desired security state of the connection to the server.MySQLConnectOptions
setSslOptions(ClientSSLOptions sslOptions)
MySQLConnectOptions
setTracingPolicy(TracingPolicy tracingPolicy)
Set the tracing policy for the client behavior when Vert.x has tracing enabled.MySQLConnectOptions
setUseAffectedRows(boolean useAffectedRows)
Sets how affected rows are calculated on update/delete/insert, if set totrue
an update that effectively does not change any data returns zero affected rows.MySQLConnectOptions
setUser(String user)
Specify the user account to be used for the authentication.JsonObject
toJson()
static MySQLConnectOptions
wrap(SqlConnectOptions options)
-
Methods inherited from class io.vertx.sqlclient.SqlConnectOptions
getCachePreparedStatements, getDatabase, getHost, getMetricsName, getPassword, getPort, getPreparedStatementCacheMaxSize, getPreparedStatementCacheSqlFilter, getProperties, getReconnectAttempts, getReconnectInterval, getSslOptions, getTracingPolicy, getUser, setMetricsName
-
-
-
-
Field Detail
-
DEFAULT_HOST
public static final String DEFAULT_HOST
- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_USER
public static final String DEFAULT_USER
- See Also:
- Constant Field Values
-
DEFAULT_PASSWORD
public static final String DEFAULT_PASSWORD
- See Also:
- Constant Field Values
-
DEFAULT_SCHEMA
public static final String DEFAULT_SCHEMA
- See Also:
- Constant Field Values
-
DEFAULT_CHARSET
public static final String DEFAULT_CHARSET
- See Also:
- Constant Field Values
-
DEFAULT_USE_AFFECTED_ROWS
public static final boolean DEFAULT_USE_AFFECTED_ROWS
- See Also:
- Constant Field Values
-
DEFAULT_SSL_MODE
public static final SslMode DEFAULT_SSL_MODE
-
DEFAULT_CHARACTER_ENCODING
public static final String DEFAULT_CHARACTER_ENCODING
- See Also:
- Constant Field Values
-
DEFAULT_PIPELINING_LIMIT
public static final int DEFAULT_PIPELINING_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MySQLConnectOptions
public MySQLConnectOptions()
-
MySQLConnectOptions
public MySQLConnectOptions(JsonObject json)
-
MySQLConnectOptions
public MySQLConnectOptions(SqlConnectOptions other)
-
MySQLConnectOptions
public MySQLConnectOptions(MySQLConnectOptions other)
-
-
Method Detail
-
wrap
public static MySQLConnectOptions wrap(SqlConnectOptions options)
- Returns:
- the
options
as MySQL specific connect options
-
fromUri
public static MySQLConnectOptions fromUri(String connectionUri) throws IllegalArgumentException
Provide aMySQLConnectOptions
configured from a connection URI.- Parameters:
connectionUri
- the connection URI to configure from- Returns:
- a
MySQLConnectOptions
parsed from the connection URI - Throws:
IllegalArgumentException
- when theconnectionUri
is in an invalid format
-
getCollation
public String getCollation()
Get the collation for the connection.- Returns:
- the MySQL collation
-
setCollation
public MySQLConnectOptions setCollation(String collation)
Set the collation for the connection.- Parameters:
collation
- the collation to set- Returns:
- a reference to this, so the API can be used fluently
-
getCharset
public String getCharset()
Get the charset for the connection.- Returns:
- the MySQL collation
-
setCharset
public MySQLConnectOptions setCharset(String charset)
Set the charset for the connection.- Parameters:
charset
- the charset to set- Returns:
- a reference to this, so the API can be used fluently
-
getCharacterEncoding
public String getCharacterEncoding()
Get the Java charset for encoding string values.- Returns:
- the charset name
-
setCharacterEncoding
public MySQLConnectOptions setCharacterEncoding(String characterEncoding)
Set the Java charset for encoding string values, this value is UTF-8 by default.- Parameters:
characterEncoding
- the Java charset to configure- Returns:
- a reference to this, so the API can be used fluently
-
isUseAffectedRows
public boolean isUseAffectedRows()
Get how affected rows are calculated on update/delete/insert.- Returns:
- how affected rows are calculated on update/delete/insert.
-
setUseAffectedRows
public MySQLConnectOptions setUseAffectedRows(boolean useAffectedRows)
Sets how affected rows are calculated on update/delete/insert, if set totrue
an update that effectively does not change any data returns zero affected rows. See mysql-affected-rows for details.- Parameters:
useAffectedRows
- whether only affected rows are count- Returns:
- a reference to this, so the API can be used fluently
-
getSslMode
public SslMode getSslMode()
Get the value of the configured SSL mode.- Returns:
- the sslmode
-
setSslMode
public MySQLConnectOptions setSslMode(SslMode sslMode)
Set theSslMode
for the client, this option can be used to specify the desired security state of the connection to the server.- Parameters:
sslMode
- the ssl-mode to specify- Returns:
- a reference to this, so the API can be used fluently
-
getAuthenticationPlugin
public MySQLAuthenticationPlugin getAuthenticationPlugin()
Get the default authentication plugin for connecting the server.- Returns:
- the authentication plugin
-
setAuthenticationPlugin
public MySQLConnectOptions setAuthenticationPlugin(MySQLAuthenticationPlugin authenticationPlugin)
Set the defaultauthentication plguin
for the client, the option will take effect at the connection start.- Parameters:
authenticationPlugin
- the auth plugin to use- Returns:
- a reference to this, so the API can be used fluently
-
setServerRsaPublicKeyPath
public MySQLConnectOptions setServerRsaPublicKeyPath(String serverRsaPublicKeyPath)
Set the path of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.- Parameters:
serverRsaPublicKeyPath
- the path of the server RSA public key- Returns:
- a reference to this, so the API can be used fluently
-
getServerRsaPublicKeyPath
public String getServerRsaPublicKeyPath()
Get the path of the server RSA public key.- Returns:
- the public key path
-
setServerRsaPublicKeyValue
public MySQLConnectOptions setServerRsaPublicKeyValue(Buffer serverRsaPublicKeyValue)
Set the value of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.- Parameters:
serverRsaPublicKeyValue
- the value of the server RSA public key- Returns:
- a reference to this, so the API can be used fluently
-
getServerRsaPublicKeyValue
public Buffer getServerRsaPublicKeyValue()
Get the value of the server RSA public key.- Returns:
- the public key value
-
getPipeliningLimit
public int getPipeliningLimit()
Get the pipelining limit count.- Returns:
- the pipelining count
-
setPipeliningLimit
public MySQLConnectOptions setPipeliningLimit(int pipeliningLimit)
Set the pipelining limit count.- Parameters:
pipeliningLimit
- the count to configure- Returns:
- a reference to this, so the API can be used fluently
-
setHost
public MySQLConnectOptions setHost(String host)
Description copied from class:SqlConnectOptions
Specify the host for connecting to the server.- Overrides:
setHost
in classSqlConnectOptions
- Parameters:
host
- the host to specify- Returns:
- a reference to this, so the API can be used fluently
-
setPort
public MySQLConnectOptions setPort(int port)
Description copied from class:SqlConnectOptions
Specify the port for connecting to the server.- Overrides:
setPort
in classSqlConnectOptions
- Parameters:
port
- the port to specify- Returns:
- a reference to this, so the API can be used fluently
-
setUser
public MySQLConnectOptions setUser(String user)
Description copied from class:SqlConnectOptions
Specify the user account to be used for the authentication.- Overrides:
setUser
in classSqlConnectOptions
- Parameters:
user
- the user to specify- Returns:
- a reference to this, so the API can be used fluently
-
setPassword
public MySQLConnectOptions setPassword(String password)
Description copied from class:SqlConnectOptions
Specify the user password to be used for the authentication.- Overrides:
setPassword
in classSqlConnectOptions
- Parameters:
password
- the password to specify- Returns:
- a reference to this, so the API can be used fluently
-
setDatabase
public MySQLConnectOptions setDatabase(String database)
Description copied from class:SqlConnectOptions
Specify the default database for the connection.- Overrides:
setDatabase
in classSqlConnectOptions
- Parameters:
database
- the database name to specify- Returns:
- a reference to this, so the API can be used fluently
-
setCachePreparedStatements
public MySQLConnectOptions setCachePreparedStatements(boolean cachePreparedStatements)
Description copied from class:SqlConnectOptions
Set whether prepared statements cache should be enabled.- Overrides:
setCachePreparedStatements
in classSqlConnectOptions
- Parameters:
cachePreparedStatements
- true if cache should be enabled- Returns:
- a reference to this, so the API can be used fluently
-
setPreparedStatementCacheMaxSize
public MySQLConnectOptions setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)
Description copied from class:SqlConnectOptions
Set the maximum number of prepared statements that the connection will cache.- Overrides:
setPreparedStatementCacheMaxSize
in classSqlConnectOptions
- Parameters:
preparedStatementCacheMaxSize
- the size to set- Returns:
- a reference to this, so the API can be used fluently
-
setPreparedStatementCacheSqlFilter
public MySQLConnectOptions setPreparedStatementCacheSqlFilter(java.util.function.Predicate<String> predicate)
Description copied from class:SqlConnectOptions
Set a predicate filtering prepared statements that the connection will cache.The default predicate accepts predicate having query length <
SqlConnectOptions.DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT
- Overrides:
setPreparedStatementCacheSqlFilter
in classSqlConnectOptions
- Parameters:
predicate
- the filter
-
setPreparedStatementCacheSqlLimit
public MySQLConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Description copied from class:SqlConnectOptions
Set the maximum length of prepared statement SQL string that the connection will cache.This is an helper setting the
SqlConnectOptions.setPreparedStatementCacheSqlFilter(Predicate)
.- Overrides:
setPreparedStatementCacheSqlLimit
in classSqlConnectOptions
- Parameters:
preparedStatementCacheSqlLimit
- the maximum length limit of SQL string to set- Returns:
- a reference to this, so the API can be used fluently
-
setProperties
public MySQLConnectOptions setProperties(Map<String,String> properties)
Description copied from class:SqlConnectOptions
Set properties for this client, which will be sent to server at the connection start.- Overrides:
setProperties
in classSqlConnectOptions
- Parameters:
properties
- the value of properties to specify- Returns:
- a reference to this, so the API can be used fluently
-
addProperty
public MySQLConnectOptions addProperty(String key, String value)
Description copied from class:SqlConnectOptions
Add a property for this client, which will be sent to server at the connection start.- Overrides:
addProperty
in classSqlConnectOptions
- Parameters:
key
- the value of property keyvalue
- the value of property value- Returns:
- a reference to this, so the API can be used fluently
-
setReconnectAttempts
public MySQLConnectOptions setReconnectAttempts(int attempts)
Description copied from class:SqlConnectOptions
Set the value of reconnect attempts- Overrides:
setReconnectAttempts
in classSqlConnectOptions
- Parameters:
attempts
- the maximum number of reconnect attempts- Returns:
- a reference to this, so the API can be used fluently
-
setReconnectInterval
public MySQLConnectOptions setReconnectInterval(long interval)
Description copied from class:SqlConnectOptions
Set the reconnect interval- Overrides:
setReconnectInterval
in classSqlConnectOptions
- Parameters:
interval
- the reconnect interval in ms- Returns:
- a reference to this, so the API can be used fluently
-
setTracingPolicy
public MySQLConnectOptions setTracingPolicy(TracingPolicy tracingPolicy)
Description copied from class:SqlConnectOptions
Set the tracing policy for the client behavior when Vert.x has tracing enabled.- Overrides:
setTracingPolicy
in classSqlConnectOptions
- Parameters:
tracingPolicy
- the tracing policy- Returns:
- a reference to this, so the API can be used fluently
-
setSslOptions
public MySQLConnectOptions setSslOptions(ClientSSLOptions sslOptions)
- Overrides:
setSslOptions
in classSqlConnectOptions
-
init
protected void init()
Initialize with the default options.- Overrides:
init
in classSqlConnectOptions
-
toJson
public JsonObject toJson()
- Overrides:
toJson
in classSqlConnectOptions
-
getSocketAddress
public SocketAddress getSocketAddress()
- Overrides:
getSocketAddress
in classSqlConnectOptions
-
isUsingDomainSocket
public boolean isUsingDomainSocket()
- Overrides:
isUsingDomainSocket
in classSqlConnectOptions
-
merge
public MySQLConnectOptions merge(JsonObject other)
Description copied from class:SqlConnectOptions
Returns new options created after this object and merged with theother
json config.- Overrides:
merge
in classSqlConnectOptions
- Parameters:
other
- the other JSON object- Returns:
- new options created after this object and merged with the
other
json config
-
-