If I don’t close an open ResultSet in Derby and the connection is using ResultSet.HOLD_CURSORS_OVER_COMMIT for holdability, what happens if I call:
connection.commit();
connection.rollback();
Is there any risk to calling rollback() once I’ve explicitly committed the current transaction? I ask because I find I always have to call rollback() before I can close the connection or I get an exception:
java.sql.SQLException: Cannot close a connection while a transaction is still active.
It’s perfectly legal to call rollback() when you haven’t performed any changes to the database.
In fact, I rollback() read-only transactions all the time.