Class UcpCredentialsUpdater
- All Implemented Interfaces:
UpdatableCredential<String>
This class implements the UpdatableCredential interface to receive credential
change notifications from the CredentialsProviderService.
When credentials are updated, it atomically updates the pool's username and password,
then triggers a pool refresh to ensure new connections use the updated credentials.
Credential Update Process
- Acquire a lock on the pool to ensure atomic credential updates
- Update the username and password on the
PoolDataSource - Call
UniversalConnectionPoolManager.refreshConnectionPool(String)to gracefully replace connections with ones using the new credentials
Thread Safety
This class is thread-safe. Credential updates are synchronized on the pool data source to ensure atomic username/password updates. The pool refresh operation is handled asynchronously by UCP.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionUcpCredentialsUpdater(oracle.ucp.jdbc.PoolDataSource poolDataSource) Creates a new credentials updater for the given Oracle UCP pool. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCredential(String username, String credential) Updates the credentials used by the Oracle UCP pool and refreshes connections.
-
Constructor Details
-
UcpCredentialsUpdater
public UcpCredentialsUpdater(oracle.ucp.jdbc.PoolDataSource poolDataSource) Creates a new credentials updater for the given Oracle UCP pool.- Parameters:
poolDataSource- the Oracle UCP PoolDataSource to manage
-
-
Method Details
-
setCredential
Updates the credentials used by the Oracle UCP pool and refreshes connections.This method atomically updates the username and password on the pool, then triggers a pool refresh. The refresh operation gracefully replaces existing connections with new ones using the updated credentials. Active connections continue to work until they are returned to the pool.
- Specified by:
setCredentialin interfaceUpdatableCredential<String>- Parameters:
username- the new database usernamecredential- the new database password- Throws:
RuntimeException- if the credentials cannot be updated or the pool cannot be refreshed
-