Interface DatabaseConfiguration
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
GenericDatabaseConfiguration
Represents a configuration interface for managing database connections.
This interface provides methods to establish, retrieve, and close a database connection while handling different SQL operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the active database connection.voidconnect(String databaseName, SqlOperation sqlOperation) Establishes a connection to the specified database.Retrieves the active database connection.
-
Method Details
-
connect
Establishes a connection to the specified database.This method connects to the database using the provided database name and SQL operation type. If the connection fails, a
DatabaseConnectionExceptionis thrown.- Parameters:
databaseName- The name of the database to connect to.sqlOperation- The type ofSqlOperationto perform.- Throws:
DatabaseConnectionException- If an error occurs while connecting to the database.
-
close
Closes the active database connection.This method ensures that all resources associated with the database connection are released. If an error occurs during closing, a
DatabaseConnectionExceptionis thrown.- Specified by:
closein interfaceAutoCloseable- Throws:
DatabaseConnectionException- If an error occurs while closing the connection.
-
getConnection
Retrieves the active database connection.If the connection is not established, this method should throw a
DatabaseConnectionException.- Returns:
- The active
Connectioninstance. - Throws:
DatabaseConnectionException- If no connection is available or an error occurs while retrieving it.
-