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 configuringMySQLConnectionorMySQLBuilder.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CHARACTER_ENCODINGstatic StringDEFAULT_CHARSETstatic Map<String,String>DEFAULT_CONNECTION_ATTRIBUTESstatic StringDEFAULT_HOSTstatic StringDEFAULT_PASSWORDstatic intDEFAULT_PIPELINING_LIMITstatic intDEFAULT_PORTstatic StringDEFAULT_SCHEMAstatic SslModeDEFAULT_SSL_MODEstatic booleanDEFAULT_USE_AFFECTED_ROWSstatic StringDEFAULT_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 MySQLConnectOptionsaddProperty(String key, String value)Add a property for this client, which will be sent to server at the connection start.static MySQLConnectOptionsfromUri(String connectionUri)Provide aMySQLConnectOptionsconfigured from a connection URI.MySQLAuthenticationPlugingetAuthenticationPlugin()Get the default authentication plugin for connecting the server.StringgetCharacterEncoding()Get the Java charset for encoding string values.StringgetCharset()Get the charset for the connection.StringgetCollation()Get the collation for the connection.intgetPipeliningLimit()Get the pipelining limit count.StringgetServerRsaPublicKeyPath()Get the path of the server RSA public key.BuffergetServerRsaPublicKeyValue()Get the value of the server RSA public key.SocketAddressgetSocketAddress()SslModegetSslMode()Get the value of the configured SSL mode.protected voidinit()Initialize with the default options.booleanisUseAffectedRows()Get how affected rows are calculated on update/delete/insert.booleanisUsingDomainSocket()MySQLConnectOptionsmerge(JsonObject other)Returns new options created after this object and merged with theotherjson config.MySQLConnectOptionssetAuthenticationPlugin(MySQLAuthenticationPlugin authenticationPlugin)Set the defaultauthentication plguinfor the client, the option will take effect at the connection start.MySQLConnectOptionssetCachePreparedStatements(boolean cachePreparedStatements)Set whether prepared statements cache should be enabled.MySQLConnectOptionssetCharacterEncoding(String characterEncoding)Set the Java charset for encoding string values, this value is UTF-8 by default.MySQLConnectOptionssetCharset(String charset)Set the charset for the connection.MySQLConnectOptionssetCollation(String collation)Set the collation for the connection.MySQLConnectOptionssetDatabase(String database)Specify the default database for the connection.MySQLConnectOptionssetHost(String host)Specify the host for connecting to the server.MySQLConnectOptionssetPassword(String password)Specify the user password to be used for the authentication.MySQLConnectOptionssetPipeliningLimit(int pipeliningLimit)Set the pipelining limit count.MySQLConnectOptionssetPort(int port)Specify the port for connecting to the server.MySQLConnectOptionssetPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)Set the maximum number of prepared statements that the connection will cache.MySQLConnectOptionssetPreparedStatementCacheSqlFilter(Predicate<String> predicate)Set a predicate filtering prepared statements that the connection will cache.MySQLConnectOptionssetPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)Set the maximum length of prepared statement SQL string that the connection will cache.MySQLConnectOptionssetProperties(Map<String,String> properties)Set properties for this client, which will be sent to server at the connection start.MySQLConnectOptionssetReconnectAttempts(int attempts)Set the value of reconnect attemptsMySQLConnectOptionssetReconnectInterval(long interval)Set the reconnect intervalMySQLConnectOptionssetServerRsaPublicKeyPath(String serverRsaPublicKeyPath)Set the path of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.MySQLConnectOptionssetServerRsaPublicKeyValue(Buffer serverRsaPublicKeyValue)Set the value of server RSA public key which is mostly used for encrypting password under insecure connections when performing authentication.MySQLConnectOptionssetSslMode(SslMode sslMode)Set theSslModefor the client, this option can be used to specify the desired security state of the connection to the server.MySQLConnectOptionssetSslOptions(ClientSSLOptions sslOptions)MySQLConnectOptionssetTracingPolicy(TracingPolicy tracingPolicy)Set the tracing policy for the client behavior when Vert.x has tracing enabled.MySQLConnectOptionssetUseAffectedRows(boolean useAffectedRows)Sets how affected rows are calculated on update/delete/insert, if set totruean update that effectively does not change any data returns zero affected rows.MySQLConnectOptionssetUser(String user)Specify the user account to be used for the authentication.JsonObjecttoJson()static MySQLConnectOptionswrap(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
optionsas MySQL specific connect options
-
fromUri
public static MySQLConnectOptions fromUri(String connectionUri) throws IllegalArgumentException
Provide aMySQLConnectOptionsconfigured from a connection URI.- Parameters:
connectionUri- the connection URI to configure from- Returns:
- a
MySQLConnectOptionsparsed from the connection URI - Throws:
IllegalArgumentException- when theconnectionUriis 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 totruean 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 theSslModefor 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 plguinfor 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:SqlConnectOptionsSpecify the host for connecting to the server.- Overrides:
setHostin 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:SqlConnectOptionsSpecify the port for connecting to the server.- Overrides:
setPortin 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:SqlConnectOptionsSpecify the user account to be used for the authentication.- Overrides:
setUserin 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:SqlConnectOptionsSpecify the user password to be used for the authentication.- Overrides:
setPasswordin 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:SqlConnectOptionsSpecify the default database for the connection.- Overrides:
setDatabasein 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:SqlConnectOptionsSet whether prepared statements cache should be enabled.- Overrides:
setCachePreparedStatementsin 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:SqlConnectOptionsSet the maximum number of prepared statements that the connection will cache.- Overrides:
setPreparedStatementCacheMaxSizein classSqlConnectOptions- Parameters:
preparedStatementCacheMaxSize- the size to set- Returns:
- a reference to this, so the API can be used fluently
-
setPreparedStatementCacheSqlFilter
public MySQLConnectOptions setPreparedStatementCacheSqlFilter(Predicate<String> predicate)
Description copied from class:SqlConnectOptionsSet 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:
setPreparedStatementCacheSqlFilterin classSqlConnectOptions- Parameters:
predicate- the filter
-
setPreparedStatementCacheSqlLimit
public MySQLConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Description copied from class:SqlConnectOptionsSet the maximum length of prepared statement SQL string that the connection will cache.This is an helper setting the
SqlConnectOptions.setPreparedStatementCacheSqlFilter(Predicate).- Overrides:
setPreparedStatementCacheSqlLimitin 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:SqlConnectOptionsSet properties for this client, which will be sent to server at the connection start.- Overrides:
setPropertiesin 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:SqlConnectOptionsAdd a property for this client, which will be sent to server at the connection start.- Overrides:
addPropertyin 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:SqlConnectOptionsSet the value of reconnect attempts- Overrides:
setReconnectAttemptsin 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:SqlConnectOptionsSet the reconnect interval- Overrides:
setReconnectIntervalin 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:SqlConnectOptionsSet the tracing policy for the client behavior when Vert.x has tracing enabled.- Overrides:
setTracingPolicyin 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:
setSslOptionsin classSqlConnectOptions
-
init
protected void init()
Initialize with the default options.- Overrides:
initin classSqlConnectOptions
-
toJson
public JsonObject toJson()
- Overrides:
toJsonin classSqlConnectOptions
-
getSocketAddress
public SocketAddress getSocketAddress()
- Overrides:
getSocketAddressin classSqlConnectOptions
-
isUsingDomainSocket
public boolean isUsingDomainSocket()
- Overrides:
isUsingDomainSocketin classSqlConnectOptions
-
merge
public MySQLConnectOptions merge(JsonObject other)
Description copied from class:SqlConnectOptionsReturns new options created after this object and merged with theotherjson config.- Overrides:
mergein classSqlConnectOptions- Parameters:
other- the other JSON object- Returns:
- new options created after this object and merged with the
otherjson config
-
-