Code example for Connection

Methods: commitrollback

0
            T result = unitOfWork.call();
            logger.debug("do unitOfWork, result = " + result);
            logger.debug("try commit"); 
            //method call can do whatever he want and than commit 
            //pattern unit of work 
            connection.commit();
            logger.debug("commit - ok"); 
            return result;
        } catch (Exception e) {
            logger.warn("some exception when do unitOfWork, try rollback", e);
            connection.rollback();
            logger.warn("rollback - ok"); 
            throw e;
        } finally { 
            logger.debug("close connection"); 
            JdbcUtils.closeQuietly(connection);
            logger.debug("unlink connection from thread. connection = " + connection + ", thread = " + Thread.currentThread());
            connectionHolder.remove();
        } 
    }