Package io.agroal.api
Interface AgroalDataSource
- All Superinterfaces:
AutoCloseable,CommonDataSource,DataSource,Serializable,Wrapper
Extension of the DataSource interface that exposes some of its internals.
The Agroal project is all about providing a good (reliable, fast, easy to use maintain and understand) implementation of this interface.
Agroal - the natural database connection pool!
- Author:
- Luis Barreiro
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumModes supported on the flush operation. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidPerforms a flush action on the connections of the pool.static AgroalDataSourcefrom(AgroalDataSourceConfiguration configuration, AgroalDataSourceListener... listeners) Create an AgroalDataSource from configuration.static AgroalDataSourcefrom(Supplier<AgroalDataSourceConfiguration> configurationSupplier, AgroalDataSourceListener... listeners) Create an AgroalDataSource from a supplier of the configuration.Allows inspection of the configuration.Allows access to metrics.Get the list of pool interceptors.default booleanisHealthy(boolean newConnection) Performs a health check.voidsetPoolInterceptors(Collection<? extends AgroalPoolInterceptor> interceptors) Sets pool interceptors.Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLoggerMethods inherited from interface javax.sql.DataSource
createConnectionBuilder, getConnection, getConnection, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriterMethods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Method Details
-
from
static AgroalDataSource from(Supplier<AgroalDataSourceConfiguration> configurationSupplier, AgroalDataSourceListener... listeners) throws SQLException Create an AgroalDataSource from a supplier of the configuration.- Throws:
SQLException
-
from
static AgroalDataSource from(AgroalDataSourceConfiguration configuration, AgroalDataSourceListener... listeners) throws SQLException Create an AgroalDataSource from configuration.- Throws:
SQLException
-
getConfiguration
AgroalDataSourceConfiguration getConfiguration()Allows inspection of the configuration. Some properties allow read / write. -
getMetrics
AgroalDataSourceMetrics getMetrics()Allows access to metrics. If metrics are not enabled, returns default values. -
flush
Performs a flush action on the connections of the pool. -
setPoolInterceptors
Sets pool interceptors. -
getPoolInterceptors
List<AgroalPoolInterceptor> getPoolInterceptors()Get the list of pool interceptors. Interceptors are sorted from high to low priority. -
isHealthy
Performs a health check. The newConnection parameter determines that a new database connection is established for this purpose, otherwise attempts to get a connection from the pool. WARNING: Using a new connection may cause the size of the pool to go over max-size.- Throws:
SQLException
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-