Class AbstractTransactionalQuery

    • Method Detail

      • ensureTransaction

        protected void ensureTransaction()
                                  throws SQLException
        Check that a transaction is active.
        Throws:
        SQLException - if no active transaction
      • releaseConnection

        protected void releaseConnection​(Connection conn,
                                         Statement statement,
                                         ResultSet rs)
                                  throws SQLException
        Closes a statement and a resultset, then releases the connection if it is not part of an active transaction. A failure in closing one of the parameters does not prevent closing the rest. If the statement is a PreparedStatement, its parameters are cleared prior to closing the statement. Although JDBC specification does state that closing a statement closes its result set and closing a connection closes statements and result sets, this method does try to close the result set and statement explicitly whenever not null. This can guard against bugs in certain JDBC drivers and reduce leaks in case e.g. closing the result set succeeds but closing the statement or connection fails.
        Parameters:
        conn - the connection to release
        statement - the statement to close, may be null to skip closing
        rs - the result set to close, may be null to skip closing
        Throws:
        SQLException - if closing the result set or the statement fails
      • getConnection

        protected Connection getConnection()
                                    throws SQLException
        Returns the currently active connection, reserves and returns a new connection if no active connection.
        Returns:
        previously active or newly reserved connection
        Throws:
        SQLException
      • isInTransaction

        protected boolean isInTransaction()