We have a class called DataLoader that loads data from a database via a connection. How should you modify the class so that it closes the connection when the Spring Container is shut down?
Java
class DataLoader {
private Connection dbConnection;
public void closeConnection() throws SQLException {
dbConnection.close();
}
}Kotlin
class DataLoader(
private val dbConnection: Connection
) {
fun closeConnection() {
dbConnection.close()
}
}