public final class DataSourceUtils extends Object
DataSource
s and its related objects.Modifier and Type | Method and Description |
---|---|
static void |
closeConnection(@Nullable Connection connection)
Simply closes a connection.
|
static void |
closePool(@Nullable AsyncDataOperations asyncDataOperations) |
static void |
closePool(@Nullable DatabaseAccessor accessor) |
static void |
closePool(@Nullable DataSource dataSource)
Closes a connection pool managed by a DataSource.
|
static void |
closeResultSet(@Nullable ResultSet resultSet) |
static void |
closeStatement(@Nullable Statement statement) |
static @Nullable Connection |
getConnection(@NotNull DataSource dataSource)
Simply gets a connection from a given valid DataSource.
|
static @NotNull DataSource |
newDataSource(@NotNull Credentials credentials)
Creates a new DataSource with the given Credentials.
|
@NotNull public static @NotNull DataSource newDataSource(@NotNull @NotNull Credentials credentials) throws DataSourceInitException
DataSourceFactory
: HikariFactory
credentials
- the credentialsDataSourceInitException
- if something went wrong during the creation of the DataSourceDataSourceFactory
,
HikariFactory
@Nullable public static @Nullable Connection getConnection(@NotNull @NotNull DataSource dataSource)
dataSource
- the datasourcepublic static void closeConnection(@Nullable @Nullable Connection connection)
connection
- the connectionpublic static void closeResultSet(@Nullable @Nullable ResultSet resultSet)
public static void closeStatement(@Nullable @Nullable Statement statement)
public static void closePool(@Nullable @Nullable DataSource dataSource)
NOTE: the provided DataSource must implement the interface Closeable
dataSource
- the DataSourceCloseable
public static void closePool(@Nullable @Nullable DatabaseAccessor accessor)
public static void closePool(@Nullable @Nullable AsyncDataOperations asyncDataOperations)
Copyright © 2021. All rights reserved.