Example usage for org.springframework.jdbc.core.metadata CallMetaDataProvider isRefCursorSupported

List of usage examples for org.springframework.jdbc.core.metadata CallMetaDataProvider isRefCursorSupported

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.metadata CallMetaDataProvider isRefCursorSupported.

Prototype

boolean isRefCursorSupported();

Source Link

Document

Does this database support returning ResultSets as ref cursors to be retrieved with java.sql.CallableStatement#getObject(int) for the specified column.

Usage

From source file:org.springframework.jdbc.core.metadata.CallMetaDataContext.java

/**
 * Create a ReturnResultSetParameter/SqlOutParameter depending on the support provided
 * by the JDBC driver used for the database in use.
 * @param parameterName the name of the parameter (also used as the name of the List returned in the output)
 * @param rowMapper a RowMapper implementation used to map the data returned in the result set
 * @return the appropriate SqlParameter/*from  w w  w .j ava2s.co  m*/
 */
public SqlParameter createReturnResultSetParameter(String parameterName, RowMapper<?> rowMapper) {
    CallMetaDataProvider provider = obtainMetaDataProvider();
    if (provider.isReturnResultSetSupported()) {
        return new SqlReturnResultSet(parameterName, rowMapper);
    } else {
        if (provider.isRefCursorSupported()) {
            return new SqlOutParameter(parameterName, provider.getRefCursorSqlType(), rowMapper);
        } else {
            throw new InvalidDataAccessApiUsageException(
                    "Return of a ResultSet from a stored procedure is not supported.");
        }
    }
}