- .
- finally.
- - . . - .
- , . .
closeDatabase(), .
:
connection connection pool .
:
public void doSomethingWithDb(Connection con, ...) {
boolean release = (con == null);
try {
con = PersistenceUtils.getConnection(con);
if(release) {
con.commit();
}
}
catch(SQLException e) {
}
finally {
if(release && con!=null){
con.close();
}
}
}
Connection , db. null Connection, .
"DB-Method" "DB-Method", , .
, JDBC . , Utility-Class, PersistenceUtils, , commit (Connection), rollback (Connection), getConnection (Connection), close (Connection)...
, - .