Configuration for MySQL database connections.
This trait provides a fluent API for configuring MySQL connection parameters including host, port, authentication, SSL settings, and various connection options.
Attributes
- Example
-
val config = MySQLConfig.default .setHost("localhost") .setPort(3306) .setUser("myuser") .setPassword("mypassword") .setDatabase("mydatabase") .setSSL(SSL.Trusted)
- Companion
- object
- Source
- MySQLConfig.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Gets the interval for adaptive pool sizing calculations. Only used when creating a pooled DataSource.
Gets the interval for adaptive pool sizing calculations. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the adaptive sizing interval duration
- Source
- MySQLConfig.scala
Gets whether adaptive pool sizing is enabled. Only used when creating a pooled DataSource.
Gets whether adaptive pool sizing is enabled. Only used when creating a pooled DataSource.
Attributes
- Returns
-
true if adaptive sizing is enabled
- Source
- MySQLConfig.scala
Gets the alive bypass window for connection validation optimization. Connections used within this window will skip validation checks.
Gets the alive bypass window for connection validation optimization. Connections used within this window will skip validation checks.
Attributes
- Returns
-
the alive bypass window duration
- Source
- MySQLConfig.scala
Whether to allow retrieval of RSA public keys from the server.
Gets the connection test query used for validation.
Gets the connection test query used for validation.
Attributes
- Returns
-
the test query, or None to use JDBC4 isValid()
- Source
- MySQLConfig.scala
Gets the maximum time to wait for a connection from the pool. Only used when creating a pooled DataSource.
Gets the maximum time to wait for a connection from the pool. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the connection timeout duration
- Source
- MySQLConfig.scala
The default database to use upon connection.
The database terminology to use (CATALOG or SCHEMA).
Whether to enable debug logging for the connection.
The hostname or IP address of the MySQL server.
Gets the maximum time a connection can remain idle in the pool. Only used when creating a pooled DataSource.
Gets the maximum time a connection can remain idle in the pool. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the idle timeout duration
- Source
- MySQLConfig.scala
Gets the keepalive time for idle connections.
Gets the keepalive time for idle connections.
Attributes
- Returns
-
the keepalive time duration, or None if disabled
- Source
- MySQLConfig.scala
Gets the threshold for connection leak detection. Only used when creating a pooled DataSource.
Gets the threshold for connection leak detection. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the leak detection threshold, or None if disabled
- Source
- MySQLConfig.scala
Gets the interval for pool maintenance tasks. Only used when creating a pooled DataSource.
Gets the interval for pool maintenance tasks. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the maintenance interval duration
- Source
- MySQLConfig.scala
Gets the maximum number of connections allowed in the connection pool. Only used when creating a pooled DataSource.
Gets the maximum number of connections allowed in the connection pool. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the maximum number of connections
- Source
- MySQLConfig.scala
Gets the maximum lifetime of a connection in the pool. Only used when creating a pooled DataSource.
Gets the maximum lifetime of a connection in the pool. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the maximum lifetime duration
- Source
- MySQLConfig.scala
Gets the minimum number of connections to maintain in the connection pool. Only used when creating a pooled DataSource.
Gets the minimum number of connections to maintain in the connection pool. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the minimum number of connections
- Source
- MySQLConfig.scala
The password for authenticating with the MySQL server, if required.
The password for authenticating with the MySQL server, if required.
Attributes
- Source
- MySQLConfig.scala
The port number on which the MySQL server is listening.
The timeout duration for read operations.
Sets the interval at which the adaptive sizing algorithm runs. The algorithm analyzes pool usage patterns and adjusts the pool size accordingly. Only applicable when using connection pooling with adaptive sizing enabled.
Sets the interval at which the adaptive sizing algorithm runs. The algorithm analyzes pool usage patterns and adjusts the pool size accordingly. Only applicable when using connection pooling with adaptive sizing enabled.
Value parameters
- interval
-
the adaptive sizing interval (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if interval <= 0
- Source
- MySQLConfig.scala
Sets whether to enable adaptive pool sizing. When enabled, the pool size will be dynamically adjusted based on load patterns. This can help optimize resource usage under varying workloads. Only applicable when using connection pooling.
Sets whether to enable adaptive pool sizing. When enabled, the pool size will be dynamically adjusted based on load patterns. This can help optimize resource usage under varying workloads. Only applicable when using connection pooling.
Value parameters
- enabled
-
true to enable adaptive sizing
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets the window during which recently used connections skip validation. This optimization reduces unnecessary database round-trips for frequently used connections. Set to 0 to disable this optimization and always validate connections.
Sets the window during which recently used connections skip validation. This optimization reduces unnecessary database round-trips for frequently used connections. Set to 0 to disable this optimization and always validate connections.
Value parameters
- window
-
the bypass window duration (must be >= 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if window < 0
- Source
- MySQLConfig.scala
Sets whether to allow retrieval of RSA public keys from the server. This is required for certain authentication plugins when SSL is not used.
Sets whether to allow retrieval of RSA public keys from the server. This is required for certain authentication plugins when SSL is not used.
Value parameters
- allowPublicKeyRetrieval
-
true to allow public key retrieval
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets a custom query for connection validation. If not set, JDBC4's isValid() method will be used (recommended). Only set this if your driver doesn't support isValid() properly.
Sets a custom query for connection validation. If not set, JDBC4's isValid() method will be used (recommended). Only set this if your driver doesn't support isValid() properly.
Value parameters
- query
-
the test query (e.g., "SELECT 1")
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets the maximum time to wait for a connection to become available from the pool. If no connection is available within this timeout, an error will be returned. Only applicable when using connection pooling.
Sets the maximum time to wait for a connection to become available from the pool. If no connection is available within this timeout, an error will be returned. Only applicable when using connection pooling.
Value parameters
- timeout
-
the connection timeout (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if timeout <= 0
- Source
- MySQLConfig.scala
Sets the default database to use upon connection.
Sets the default database to use upon connection.
Value parameters
- database
-
the database name
Attributes
- Returns
-
a new MySQLConfig with the updated database
- Source
- MySQLConfig.scala
Sets the database terminology to use. MySQL traditionally uses CATALOG, but this can be configured.
Sets the database terminology to use. MySQL traditionally uses CATALOG, but this can be configured.
Value parameters
- databaseTerm
-
the database term (CATALOG or SCHEMA)
Attributes
- Returns
-
a new MySQLConfig with the updated database term
- Source
- MySQLConfig.scala
Enables or disables debug logging for the connection.
Enables or disables debug logging for the connection.
Value parameters
- debug
-
true to enable debug logging, false to disable
Attributes
- Returns
-
a new MySQLConfig with the updated debug setting
- Source
- MySQLConfig.scala
Sets the hostname or IP address of the MySQL server.
Sets the hostname or IP address of the MySQL server.
Value parameters
- host
-
the hostname or IP address
Attributes
- Returns
-
a new MySQLConfig with the updated host
- Source
- MySQLConfig.scala
Sets the maximum time a connection can remain idle in the pool before being closed. Idle connections exceeding this timeout will be removed to free resources. Only applicable when using connection pooling.
Sets the maximum time a connection can remain idle in the pool before being closed. Idle connections exceeding this timeout will be removed to free resources. Only applicable when using connection pooling.
Value parameters
- timeout
-
the idle timeout (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if timeout <= 0
- Source
- MySQLConfig.scala
Sets the interval at which idle connections are validated. This helps prevent connection timeouts due to firewalls or idle timeouts. The actual keepalive time will vary by up to 20% to avoid synchronized validations.
Sets the interval at which idle connections are validated. This helps prevent connection timeouts due to firewalls or idle timeouts. The actual keepalive time will vary by up to 20% to avoid synchronized validations.
Value parameters
- time
-
the keepalive interval (must be >= 30 seconds)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if time < 30 seconds
- Source
- MySQLConfig.scala
Sets the threshold for connection leak detection. If a connection is not returned to the pool within this time, it's considered leaked. A warning will be logged to help identify connection leaks in the application. Only applicable when using connection pooling.
Sets the threshold for connection leak detection. If a connection is not returned to the pool within this time, it's considered leaked. A warning will be logged to help identify connection leaks in the application. Only applicable when using connection pooling.
Value parameters
- threshold
-
the leak detection threshold
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets the interval at which pool maintenance tasks are performed. Maintenance includes removing idle connections, validating connections, etc. Only applicable when using connection pooling.
Sets the interval at which pool maintenance tasks are performed. Maintenance includes removing idle connections, validating connections, etc. Only applicable when using connection pooling.
Value parameters
- interval
-
the maintenance interval (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if interval <= 0
- Source
- MySQLConfig.scala
Sets the maximum number of connections allowed in the connection pool. The pool will not create more connections than this limit. Only applicable when using connection pooling.
Sets the maximum number of connections allowed in the connection pool. The pool will not create more connections than this limit. Only applicable when using connection pooling.
Value parameters
- max
-
the maximum number of connections (must be >= minConnections)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if max < minConnections
- Source
- MySQLConfig.scala
Sets the maximum lifetime of a connection in the pool. Connections older than this will be retired and replaced with fresh connections. This helps prevent issues with long-lived connections. Only applicable when using connection pooling.
Sets the maximum lifetime of a connection in the pool. Connections older than this will be retired and replaced with fresh connections. This helps prevent issues with long-lived connections. Only applicable when using connection pooling.
Value parameters
- maxLifetime
-
the maximum lifetime (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if maxLifetime <= 0
- Source
- MySQLConfig.scala
Sets the minimum number of connections to maintain in the connection pool. This ensures that at least this many connections are always available for use. Only applicable when using connection pooling.
Sets the minimum number of connections to maintain in the connection pool. This ensures that at least this many connections are always available for use. Only applicable when using connection pooling.
Value parameters
- min
-
the minimum number of connections (must be >= 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if min < 0
- Source
- MySQLConfig.scala
Sets the password for MySQL authentication.
Sets the password for MySQL authentication.
Value parameters
- password
-
the password
Attributes
- Returns
-
a new MySQLConfig with the updated password
- Source
- MySQLConfig.scala
Sets the port number for the MySQL connection.
Sets the port number for the MySQL connection.
Value parameters
- port
-
the port number (typically 3306)
Attributes
- Returns
-
a new MySQLConfig with the updated port
- Source
- MySQLConfig.scala
Sets the timeout duration for read operations.
Sets the timeout duration for read operations.
Value parameters
- readTimeout
-
the read timeout duration, or Duration.Inf for no timeout
Attributes
- Returns
-
a new MySQLConfig with the updated read timeout
- Source
- MySQLConfig.scala
Sets the SSL configuration for secure connections.
Sets the SSL configuration for secure connections.
Value parameters
- ssl
-
the SSL configuration (None, Trusted, or System)
Attributes
- Returns
-
a new MySQLConfig with the updated SSL setting
- Source
- MySQLConfig.scala
Sets socket-level options for the TCP connection.
Sets socket-level options for the TCP connection.
Value parameters
- socketOptions
-
list of socket options to apply
Attributes
- Returns
-
a new MySQLConfig with the updated socket options
- Source
- MySQLConfig.scala
Sets whether to use cursor-based fetching for result sets. This can improve memory usage for large result sets.
Sets whether to use cursor-based fetching for result sets. This can improve memory usage for large result sets.
Value parameters
- useCursorFetch
-
true to enable cursor-based fetching
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets whether to use server-side prepared statements. Server-side prepared statements can improve performance for repeated queries.
Sets whether to use server-side prepared statements. Server-side prepared statements can improve performance for repeated queries.
Value parameters
- useServerPrepStmts
-
true to enable server-side prepared statements
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Source
- MySQLConfig.scala
Sets the username for MySQL authentication.
Sets the username for MySQL authentication.
Value parameters
- user
-
the username
Attributes
- Returns
-
a new MySQLConfig with the updated user
- Source
- MySQLConfig.scala
Sets the maximum time to wait for connection validation to complete. Connections are validated before being handed out from the pool. Only applicable when using connection pooling.
Sets the maximum time to wait for connection validation to complete. Connections are validated before being handed out from the pool. Only applicable when using connection pooling.
Value parameters
- timeout
-
the validation timeout (must be > 0)
Attributes
- Returns
-
a new MySQLConfig with the updated setting
- Throws
-
IllegalArgumentException
if timeout <= 0
- Source
- MySQLConfig.scala
Socket-level options for the TCP connection.
The SSL configuration for secure connections.
Whether to use cursor-based fetching for result sets.
Whether to use server-side prepared statements.
The username for authenticating with the MySQL server.
Gets the maximum time to wait for connection validation. Only used when creating a pooled DataSource.
Gets the maximum time to wait for connection validation. Only used when creating a pooled DataSource.
Attributes
- Returns
-
the validation timeout duration
- Source
- MySQLConfig.scala