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 TypeMethodDescriptionvoid
close()
Closes the active database connection.void
connect
(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
DatabaseConnectionException
is thrown.- Parameters:
databaseName
- The name of the database to connect to.sqlOperation
- The type ofSqlOperation
to 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
DatabaseConnectionException
is thrown.- Specified by:
close
in 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
Connection
instance. - Throws:
DatabaseConnectionException
- If no connection is available or an error occurs while retrieving it.
-