Class SqlConnectOptions
java.lang.Object
io.vertx.sqlclient.SqlConnectOptions
- Direct Known Subclasses:
DB2ConnectOptions, MSSQLConnectOptions, MySQLConnectOptions, OracleConnectOptions, PgConnectOptions
Connect options for configuring
SqlConnection or Pool.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final Stringstatic final intstatic final intstatic final intstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProperty(String key, String value) Add a property for this client, which will be sent to server at the connection start.static SqlConnectOptionsProvide aSqlConnectOptionssubclass configured fromconnectionUri.booleanGet whether prepared statements cache is enabled.Get the default database name for the connection.getHost()Get the host for connecting to the server.Get the user password to be used for the authentication.intgetPort()Get the port for connecting to the server.intGet the maximum number of prepared statements that the connection will cache.Get the predicate filtering prepared statements that the connection will cache.intlonggetUser()Get the user account to be used for the authentication.protected voidinit()Initialize with the default options.booleanmerge(JsonObject other) Returns new options created after this object and merged with theotherjson config.setCachePreparedStatements(boolean cachePreparedStatements) Set whether prepared statements cache should be enabled.setDatabase(String database) Specify the default database for the connection.Specify the host for connecting to the server.setMetricsName(String metricsName) Set the metrics name identifying the reported metrics, useful for grouping metrics with the same name.setPassword(String password) Specify the user password to be used for the authentication.setPort(int port) Specify the port for connecting to the server.setPreparedStatementCacheMaxSize(int preparedStatementCacheMaxSize) Set the maximum number of prepared statements that the connection will cache.setPreparedStatementCacheSqlFilter(Predicate<String> predicate) Set a predicate filtering prepared statements that the connection will cache.setPreparedStatementCacheSqlLimit(int preparedStatementCacheSqlLimit) Set the maximum length of prepared statement SQL string that the connection will cache.setProperties(Map<String, String> properties) Set properties for this client, which will be sent to server at the connection start.setReconnectAttempts(int attempts) Set the value of reconnect attemptssetReconnectInterval(long interval) Set the reconnect intervalsetSslOptions(ClientSSLOptions sslOptions) setTracingPolicy(TracingPolicy tracingPolicy) Set the tracing policy for the client behavior when Vert.x has tracing enabled.Specify the user account to be used for the authentication.toJson()
-
Field Details
-
DEFAULT_RECONNECT_ATTEMPTS
public static final int DEFAULT_RECONNECT_ATTEMPTS- See Also:
-
DEFAULT_RECONNECT_INTERVAL
public static final long DEFAULT_RECONNECT_INTERVAL- See Also:
-
DEFAULT_CACHE_PREPARED_STATEMENTS
public static final boolean DEFAULT_CACHE_PREPARED_STATEMENTS- See Also:
-
DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_MAX_SIZE- See Also:
-
DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT
public static final int DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT- See Also:
-
DEFAULT_PREPARED_STATEMENT_CACHE_FILTER
-
DEFAULT_METRICS_NAME
- See Also:
-
-
Constructor Details
-
SqlConnectOptions
public SqlConnectOptions() -
SqlConnectOptions
-
SqlConnectOptions
-
-
Method Details
-
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
-
setHost
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
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
-
setUser
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
Get the user password to be used for the authentication.- Returns:
- the password
-
setPassword
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
Get the default database name for the connection.- Returns:
- the database name
-
setDatabase
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
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
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
-
setPreparedStatementCacheSqlFilter
Set a predicate filtering prepared statements that the connection will cache.The default predicate accepts predicate having query length invalid input: '<'
DEFAULT_PREPARED_STATEMENT_CACHE_SQL_LIMIT- Parameters:
predicate- the filter
-
setPreparedStatementCacheSqlLimit
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
-
setProperties
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
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
-
getTracingPolicy
- Returns:
- the tracing policy
-
setTracingPolicy
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
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
Set the reconnect interval- Parameters:
interval- the reconnect interval in ms- Returns:
- a reference to this, so the API can be used fluently
-
getMetricsName
- Returns:
- the metrics name identifying the reported metrics.
-
setMetricsName
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
-
setSslOptions
-
toJson
-
init
protected void init()Initialize with the default options. -
merge
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
-