Verwenden Sie statt der Methode finalize() eine Bereinigungsmethode, die explizit aufgerufen wird.
public void free() {
Connection connection = null;
try {
Driver driver = DBUtility.getDriver();
connection = driver.connect(DBUtility.getDBURL(), DBUtility.getUserProperties());
connection.commit();
}
catch (SQLException exc) {
LogUtility.log(exc);
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (SQLException exc) {
LogUtility.log(exc);
}
}
}
}
|
|