public final class AWSSecretsManagerMySQLDriver extends AWSSecretsManagerDriver
Provides support for accessing MySQL databases using credentials stored within AWS Secrets Manager.
This will also work for MariaDB, as the error codes are the same.
Configuration properties are specified using the "mysql" subprefix (e.g drivers.mysql.realDriverClass).
| Modifier and Type | Field and Description |
|---|---|
static int |
ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE
The MySQL error code for when a user logs in using an invalid password.
|
static String |
SUBPREFIX
Set to mysql.
|
INVALID_SECRET_STRING_JSON, MAX_RETRY, PROPERTY_PREFIX, SCHEME| Constructor and Description |
|---|
AWSSecretsManagerMySQLDriver()
Constructs the driver setting the properties from the properties file using system properties as defaults.
|
AWSSecretsManagerMySQLDriver(com.amazonaws.services.secretsmanager.AWSSecretsManager client)
Constructs the driver setting the properties from the properties file using system properties as defaults.
|
AWSSecretsManagerMySQLDriver(com.amazonaws.services.secretsmanager.AWSSecretsManagerClientBuilder builder)
Constructs the driver setting the properties from the properties file using system properties as defaults.
|
AWSSecretsManagerMySQLDriver(com.amazonaws.secretsmanager.caching.SecretCache cache)
Constructs the driver setting the properties from the properties file using system properties as defaults.
|
AWSSecretsManagerMySQLDriver(com.amazonaws.secretsmanager.caching.SecretCacheConfiguration cacheConfig)
Constructs the driver setting the properties from the properties file using system properties as defaults.
|
| Modifier and Type | Method and Description |
|---|---|
String |
constructUrlFromEndpointPortDatabase(String endpoint,
String port,
String dbname)
Construct a database URL from the endpoint, port and database name.
|
String |
getDefaultDriverClass()
Get the default real driver class name for this driver.
|
String |
getPropertySubprefix()
Gets the "subprefix" used for configuration properties for this driver.
|
boolean |
isExceptionDueToAuthenticationError(Exception e)
Determines whether or not an
Exception is due to an authentication failure with the remote
database. |
acceptsURL, connect, getMajorVersion, getMinorVersion, getParentLogger, getPropertyInfo, getWrappedDriver, jdbcCompliant, registerpublic static final int ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE
public static final String SUBPREFIX
public AWSSecretsManagerMySQLDriver()
public AWSSecretsManagerMySQLDriver(com.amazonaws.secretsmanager.caching.SecretCache cache)
cache - Secret cache to use to retrieve secretspublic AWSSecretsManagerMySQLDriver(com.amazonaws.services.secretsmanager.AWSSecretsManagerClientBuilder builder)
builder - Builder used to instantiate cachepublic AWSSecretsManagerMySQLDriver(com.amazonaws.services.secretsmanager.AWSSecretsManager client)
client - AWS Secrets Manager client to instantiate cachepublic AWSSecretsManagerMySQLDriver(com.amazonaws.secretsmanager.caching.SecretCacheConfiguration cacheConfig)
cacheConfig - Cache configuration to instantiate cachepublic String getPropertySubprefix()
AWSSecretsManagerDrivergetPropertySubprefix in class AWSSecretsManagerDriverpublic boolean isExceptionDueToAuthenticationError(Exception e)
AWSSecretsManagerDriverException is due to an authentication failure with the remote
database. This method is called during connect to decide if authentication needs to be attempted
again with refreshed credentials. A good way to implement this is to look up the error codes that
java.sqlSQLExceptions will have when an authentication failure occurs. These are database
specific.isExceptionDueToAuthenticationError in class AWSSecretsManagerDrivere - The Exception to test.Exception indicates that
the credentials used for authentication are stale.public String constructUrlFromEndpointPortDatabase(String endpoint, String port, String dbname)
AWSSecretsManagerDriverconnect method is called with a secret ID instead of a URL.constructUrlFromEndpointPortDatabase in class AWSSecretsManagerDriverendpoint - The endpoint retrieved from the secret cacheport - The port retrieved from the secret cachedbname - The database name retrieved from the secret cachepublic String getDefaultDriverClass()
AWSSecretsManagerDrivergetDefaultDriverClass in class AWSSecretsManagerDriverCopyright © 2023. All rights reserved.