}
}
+ protected void closeConnections() {
+ LinkedList<MDatabaseConnection> databaseConnections = this.getDatabaseConnections();
+ while (0 < databaseConnections.size()) {
+ MDatabaseConnection databaseConnection = databaseConnections.removeLast();
+ //
+ try {
+ databaseConnection.close();
+ }
+ catch (MDatabaseConnectionFailureException exception) {
+ }
+ }
+ }
+
+ protected void finalize() {
+ this.closeConnections();
+ }
+
/* Database connection generator. */
protected MDatabaseConnectionGenerator getDatabaseConnectionGenerator() {
if (null == databaseConnection) {
throw new IllegalArgumentException("Invalid 'databaseConnection': null.");
}
- else if (!this.getDatabaseConnectionGenerator().isGeneratorFor(databaseConnection)) {
- throw new IllegalArgumentException("Invalid 'databaseConnection': not compatible with this database connection pool.");
- }
else if (databaseConnection.isClosed()) {
throw new IllegalArgumentException("Invalid 'databaseConnection': closed.");
}
//
- LinkedList<MDatabaseConnection> databaseConnections = this.getDatabaseConnections();
- if (this.getMaximumSize() >= databaseConnections.size()) {
- databaseConnections.add(databaseConnection);
+ if (!this.getDatabaseConnectionGenerator().isGeneratorFor(databaseConnection)) {
+ databaseConnection.close();
+ }
+ else {
+ LinkedList<MDatabaseConnection> databaseConnections = this.getDatabaseConnections();
+ if (this.getMaximumSize() >= databaseConnections.size()) {
+ databaseConnections.add(databaseConnection);
+ }
}
}