Savepoints consume resources, so you might conceivably want to release a savepoint that you had determined you would never need to roll back to. For example if you were running a loop to perform operations on the database you might well establish a savepoint at the beginning of the loop, but on each iteration want to release the previous savepoint.
In practice it tends not to be very useful. If you need to ask the question you probably don't need to use it.
> i understand now.
No you don't, read my reply more carefully. I meant exactly what I said.
(edit) Here's an example to make it clearer:
Connection c = ...
try {
c.setAutoCommit(false); // Begin TX
for( int i = 0; i < 10000; i++ ) {
Savepoint s = c.setSavepoint("Loop savepoint " + i);
// perform update on database for index i
...
// perform read on database for index i
...
if( !isResultAsExpected() ) {
c.rollback(s);
} else {
// Prevents the savepoint from consuming
// resources in perpetuity.
c.releaseSavepoint(s);
}
}
// Only commit when all processing complete
c.commit();
} catch( SQLException e ) {
rollbackAndLog("...",c,e);
} finally {
close(c);
}