Package com.glyart.asql.common.database
Interface DataSourceHandler
-
- All Known Implementing Classes:
DefaultDataSourceHandler
public interface DataSourceHandler
Represents the interaction logic for a data source.Different implementations may change the logic of methods
open()
andclose()
.NOTE: implementations should do a little exception (although it may not be necessary) handling for methods
open()
andclose()
, when the adopted strategy isStrategy.CONNECTION_POOL
.This is because the DataTemplate class cannot handle these methods when they are dealing with a connection pool.
This is not needed when the adopted strategy is
Strategy.SIMPLE_CONNECTION
: those methods will be managed by aSQL DataTemplate and possible exceptions will be passed to a CompletableFuture for further analysis by the user.- See Also:
DataSourceCredentials
,Strategy
,DataTemplate
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes the connection to a data source.Connection
getConnection()
Gets the existing connection to a data source.Strategy
getStrategy()
Gets the implementation's adopted strategy.void
open()
Opens the connection to a data source.
-
-
-
Method Detail
-
getConnection
@NotNull Connection getConnection() throws SQLException
Gets the existing connection to a data source.- Returns:
- The connection to a data source
- Throws:
SQLException
- if something gone wrong while attempting to get the connection (no need to catch)
-
open
void open() throws SQLException
Opens the connection to a data source.
It can be used for opening connection pools.- Throws:
SQLException
- if something gone wrong while attempting to perform the implemented open operation. No need to catch withStrategy.SIMPLE_CONNECTION
-
close
void close() throws SQLException
Closes the connection to a data source.
It can be used for closing connection pools.- Throws:
SQLException
- if something gone wrong while attempting to perform the implemented close operation. No need to catch withStrategy.SIMPLE_CONNECTION
-
-