Example usage for org.springframework.jca.cci CannotGetCciConnectionException CannotGetCciConnectionException

List of usage examples for org.springframework.jca.cci CannotGetCciConnectionException CannotGetCciConnectionException

Introduction

In this page you can find the example usage for org.springframework.jca.cci CannotGetCciConnectionException CannotGetCciConnectionException.

Prototype

public CannotGetCciConnectionException(String msg, ResourceException ex) 

Source Link

Document

Constructor for CannotGetCciConnectionException.

Usage

From source file:org.springframework.jca.cci.connection.ConnectionFactoryUtils.java

/**
 * Obtain a Connection from the given ConnectionFactory. Translates ResourceExceptions
 * into the Spring hierarchy of unchecked generic data access exceptions, simplifying
 * calling code and making any exception that is thrown more meaningful.
 * <p>Is aware of a corresponding Connection bound to the current thread, for example
 * when using {@link CciLocalTransactionManager}. Will bind a Connection to the thread
 * if transaction synchronization is active (e.g. if in a JTA transaction).
 * @param cf the ConnectionFactory to obtain Connection from
 * @param spec the ConnectionSpec for the desired Connection (may be {@code null}).
 * Note: If this is specified, a new Connection will be obtained for every call,
 * without participating in a shared transactional Connection.
 * @return a CCI Connection from the given ConnectionFactory
 * @throws org.springframework.jca.cci.CannotGetCciConnectionException
 * if the attempt to get a Connection failed
 * @see #releaseConnection/*from   w ww  . j av a  2  s .  c  o  m*/
 */
public static Connection getConnection(ConnectionFactory cf, @Nullable ConnectionSpec spec)
        throws CannotGetCciConnectionException {
    try {
        if (spec != null) {
            Assert.notNull(cf, "No ConnectionFactory specified");
            return cf.getConnection(spec);
        } else {
            return doGetConnection(cf);
        }
    } catch (ResourceException ex) {
        throw new CannotGetCciConnectionException("Could not get CCI Connection", ex);
    }
}