Example usage for org.springframework.jca.cci.connection ConnectionFactoryUtils getConnection

List of usage examples for org.springframework.jca.cci.connection ConnectionFactoryUtils getConnection

Introduction

In this page you can find the example usage for org.springframework.jca.cci.connection ConnectionFactoryUtils getConnection.

Prototype

public static Connection getConnection(ConnectionFactory cf, @Nullable ConnectionSpec spec)
        throws CannotGetCciConnectionException 

Source Link

Document

Obtain a Connection from the given ConnectionFactory.

Usage

From source file:org.springframework.jca.cci.core.CciTemplate.java

@Override
@Nullable/*w  w w .j a va2s  .  co  m*/
public <T> T execute(ConnectionCallback<T> action) throws DataAccessException {
    Assert.notNull(action, "Callback object must not be null");
    ConnectionFactory connectionFactory = obtainConnectionFactory();
    Connection con = ConnectionFactoryUtils.getConnection(connectionFactory, getConnectionSpec());
    try {
        return action.doInConnection(con, connectionFactory);
    } catch (NotSupportedException ex) {
        throw new CciOperationNotSupportedException("CCI operation not supported by connector", ex);
    } catch (ResourceException ex) {
        throw new DataAccessResourceFailureException("CCI operation failed", ex);
    } catch (SQLException ex) {
        throw new InvalidResultSetAccessException("Parsing of CCI ResultSet failed", ex);
    } finally {
        ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
    }
}