JCR-2191: Prevent java.sql.SQLException: Connection is closed