Package io.vertx.sqlclient
Class SqlConnectOptions
- java.lang.Object
-
- io.vertx.sqlclient.SqlConnectOptions
-
- Direct Known Subclasses:
DB2ConnectOptions,MSSQLConnectOptions,MySQLConnectOptions,OracleConnectOptions,PgConnectOptions
public class SqlConnectOptions extends Object
Connect options for configuringSqlConnectionorPool.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CACHE_PREPARED_STATEMENTSstatic StringDEFAULT_METRICS_NAMEstatic Predicate<String>DEFAULT_PREPARED_STATEMENT_CACHE_FILTERstatic intDEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZEstatic intDEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMITstatic intDEFAULT_RECONNECT_ATTEMPTSstatic longDEFAULT_RECONNECT_INTERVAL
-
Constructor Summary
Constructors Constructor Description SqlConnectOptions()SqlConnectOptions(JsonObject json)SqlConnectOptions(SqlConnectOptions other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlConnectOptionsaddProperty(String key, String value)Add a property for this client, which will be sent to server at the connection start.static SqlConnectOptionsfromUri(String connectionUri)Provide aSqlConnectOptionssubclass configured fromconnectionUri.booleangetCachePreparedStatements()Get whether prepared statements cache is enabled.StringgetDatabase()Get the default database name for the connection.StringgetHost()Get the host for connecting to the server.StringgetMetricsName()StringgetPassword()Get the user password to be used for the authentication.intgetPort()Get the port for connecting to the server.intgetPreparedStatementCacheMaxSize()Get the maximum number of prepared statements that the connection will cache.Predicate<String>getPreparedStatementCacheSqlFilter()Get the predicate filtering prepared statements that the connection will cache.Map<String,String>getProperties()intgetReconnectAttempts()longgetReconnectInterval()SocketAddressgetSocketAddress()ClientSSLOptionsgetSslOptions()TracingPolicygetTracingPolicy()StringgetUser()Get the user account to be used for the authentication.protected voidinit()Initialize with the default options.booleanisUsingDomainSocket()SqlConnectOptionsmerge(JsonObject other)Returns new options created after this object and merged with theotherjson config.SqlConnectOptionssetCachePreparedStatements(boolean cachePreparedStatements)Set whether prepared statements cache should be enabled.SqlConnectOptionssetDatabase(String database)Specify the default database for the connection.SqlConnectOptionssetHost(String host)Specify the host for connecting to the server.SqlConnectOptionssetMetricsName(String metricsName)Set the metrics name identifying the reported metrics, useful for grouping metrics with the same name.SqlConnectOptionssetPassword(String password)Specify the user password to be used for the authentication.SqlConnectOptionssetPort(int port)Specify the port for connecting to the server.SqlConnectOptionssetPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)Set the maximum number of prepared statements that the connection will cache.SqlConnectOptionssetPreparedStatementCacheSqlFilter(Predicate<String> predicate)Set a predicate filtering prepared statements that the connection will cache.SqlConnectOptionssetPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)Set the maximum length of prepared statement SQL string that the connection will cache.SqlConnectOptionssetProperties(Map<String,String> properties)Set properties for this client, which will be sent to server at the connection start.SqlConnectOptionssetReconnectAttempts(int attempts)Set the value of reconnect attemptsSqlConnectOptionssetReconnectInterval(long interval)Set the reconnect intervalSqlConnectOptionssetSslOptions(ClientSSLOptions sslOptions)SqlConnectOptionssetTracingPolicy(TracingPolicy tracingPolicy)Set the tracing policy for the client behavior when Vert.x has tracing enabled.SqlConnectOptionssetUser(String user)Specify the user account to be used for the authentication.JsonObjecttoJson()
-
-
-
Field Detail
-
DEFAULT_RECONNECT_ATTEMPTS
public static final int DEFAULT_RECONNECT_ATTEMPTS
- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_INTERVAL
public static final long DEFAULT_RECONNECT_INTERVAL
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_PREPARED_STATEMENTS
public static final boolean DEFAULT_CACHE_PREPARED_STATEMENTS
- See Also:
- Constant Field Values
-
DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_PREPARED_STATEMENT_CACHE_FILTER
public static final Predicate<String> DEFAULT_PREPARED_STATEMENT_CACHE_FILTER
-
DEFAULT_METRICS_NAME
public static final String DEFAULT_METRICS_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SqlConnectOptions
public SqlConnectOptions()
-
SqlConnectOptions
public SqlConnectOptions(JsonObject json)
-
SqlConnectOptions
public SqlConnectOptions(SqlConnectOptions other)
-
-
Method Detail
-
fromUri
public static SqlConnectOptions fromUri(String connectionUri) throws IllegalArgumentException, ServiceConfigurationError
Provide aSqlConnectOptionssubclass configured fromconnectionUri.This tries to locate among the available databases implementations the one matching the connection URI protocol, e.g this returns
PgConnectOptionsfor an URI that starts withpostgresql://.- Parameters:
connectionUri- the connection URI to configure from- Returns:
- a
SqlConnectOptionsparsed from the connection URI - Throws:
IllegalArgumentException- when theconnectionUriis in an invalid formatServiceConfigurationError- when a database for theconnectionUricould not be found
-
getHost
public String getHost()
Get the host for connecting to the server.- Returns:
- the host
-
setHost
public SqlConnectOptions setHost(String host)
Specify the host for connecting to the server.- Parameters:
host- the host to specify- Returns:
- a reference to this, so the API can be used fluently
-
getPort
public int getPort()
Get the port for connecting to the server.- Returns:
- the port
-
setPort
public SqlConnectOptions setPort(int port)
Specify the port for connecting to the server.- Parameters:
port- the port to specify- Returns:
- a reference to this, so the API can be used fluently
-
getUser
public String getUser()
Get the user account to be used for the authentication.- Returns:
- the user
-
setUser
public SqlConnectOptions setUser(String user)
Specify the user account to be used for the authentication.- Parameters:
user- the user to specify- Returns:
- a reference to this, so the API can be used fluently
-
getPassword
public String getPassword()
Get the user password to be used for the authentication.- Returns:
- the password
-
setPassword
public SqlConnectOptions setPassword(String password)
Specify the user password to be used for the authentication.- Parameters:
password- the password to specify- Returns:
- a reference to this, so the API can be used fluently
-
getDatabase
public String getDatabase()
Get the default database name for the connection.- Returns:
- the database name
-
setDatabase
public SqlConnectOptions setDatabase(String database)
Specify the default database for the connection.- Parameters:
database- the database name to specify- Returns:
- a reference to this, so the API can be used fluently
-
getCachePreparedStatements
public boolean getCachePreparedStatements()
Get whether prepared statements cache is enabled.- Returns:
- the value
-
setCachePreparedStatements
public SqlConnectOptions setCachePreparedStatements(boolean cachePreparedStatements)
Set whether prepared statements cache should be enabled.- Parameters:
cachePreparedStatements- true if cache should be enabled- Returns:
- a reference to this, so the API can be used fluently
-
getPreparedStatementCacheMaxSize
public int getPreparedStatementCacheMaxSize()
Get the maximum number of prepared statements that the connection will cache.- Returns:
- the size
-
setPreparedStatementCacheMaxSize
public SqlConnectOptions setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize)
Set the maximum number of prepared statements that the connection will cache.- Parameters:
preparedStatementCacheMaxSize- the size to set- Returns:
- a reference to this, so the API can be used fluently
-
getPreparedStatementCacheSqlFilter
public Predicate<String> getPreparedStatementCacheSqlFilter()
Get the predicate filtering prepared statements that the connection will cache.- Returns:
- the current predicate
-
setPreparedStatementCacheSqlFilter
public SqlConnectOptions setPreparedStatementCacheSqlFilter(Predicate<String> predicate)
Set a predicate filtering prepared statements that the connection will cache.The default predicate accepts predicate having query length <
DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT- Parameters:
predicate- the filter
-
setPreparedStatementCacheSqlLimit
public SqlConnectOptions setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit)
Set the maximum length of prepared statement SQL string that the connection will cache.This is an helper setting the
setPreparedStatementCacheSqlFilter(Predicate).- Parameters:
preparedStatementCacheSqlLimit- the maximum length limit of SQL string to set- Returns:
- a reference to this, so the API can be used fluently
-
getProperties
public Map<String,String> getProperties()
- Returns:
- the value of current connection properties
-
setProperties
public SqlConnectOptions setProperties(Map<String,String> properties)
Set properties for this client, which will be sent to server at the connection start.- Parameters:
properties- the value of properties to specify- Returns:
- a reference to this, so the API can be used fluently
-
addProperty
public SqlConnectOptions addProperty(String key, String value)
Add a property for this client, which will be sent to server at the connection start.- Parameters:
key- the value of property keyvalue- the value of property value- Returns:
- a reference to this, so the API can be used fluently
-
getSocketAddress
public SocketAddress getSocketAddress()
-
getTracingPolicy
public TracingPolicy getTracingPolicy()
- Returns:
- the tracing policy
-
setTracingPolicy
public SqlConnectOptions setTracingPolicy(TracingPolicy tracingPolicy)
Set the tracing policy for the client behavior when Vert.x has tracing enabled.- Parameters:
tracingPolicy- the tracing policy- Returns:
- a reference to this, so the API can be used fluently
-
isUsingDomainSocket
public boolean isUsingDomainSocket()
-
getReconnectAttempts
public int getReconnectAttempts()
- Returns:
- the value of reconnect attempts
-
setReconnectAttempts
public SqlConnectOptions setReconnectAttempts(int attempts)
Set the value of reconnect attempts- Parameters:
attempts- the maximum number of reconnect attempts- Returns:
- a reference to this, so the API can be used fluently
-
getReconnectInterval
public long getReconnectInterval()
- Returns:
- the value of reconnect interval
-
setReconnectInterval
public SqlConnectOptions setReconnectInterval(long interval)
Set the reconnect interval- Parameters:
interval- the reconnect interval in ms- Returns:
- a reference to this, so the API can be used fluently
-
getMetricsName
public String getMetricsName()
- Returns:
- the metrics name identifying the reported metrics.
-
setMetricsName
public SqlConnectOptions setMetricsName(String metricsName)
Set the metrics name identifying the reported metrics, useful for grouping metrics with the same name.- Parameters:
metricsName- the metrics name- Returns:
- a reference to this, so the API can be used fluently
-
getSslOptions
public ClientSSLOptions getSslOptions()
-
setSslOptions
public SqlConnectOptions setSslOptions(ClientSSLOptions sslOptions)
-
toJson
public JsonObject toJson()
-
init
protected void init()
Initialize with the default options.
-
merge
public SqlConnectOptions merge(JsonObject other)
Returns new options created after this object and merged with theotherjson config.- Parameters:
other- the other JSON object- Returns:
- new options created after this object and merged with the
otherjson config
-
-