Example usage for org.springframework.jdbc.core ResultSetSupportingSqlParameter getName

List of usage examples for org.springframework.jdbc.core ResultSetSupportingSqlParameter getName

Introduction

In this page you can find the example usage for org.springframework.jdbc.core ResultSetSupportingSqlParameter getName.

Prototype

@Nullable
public String getName() 

Source Link

Document

Return the name of the parameter, or null if anonymous.

Usage

From source file:cc.tooyoung.common.db.JdbcTemplate.java

/**
 * Process the given ResultSet from a stored procedure.
 * @param rs the ResultSet to process//from   w  w  w  . jav  a 2s . com
 * @param param the corresponding stored procedure parameter
 * @return Map that contains returned results
 */
@SuppressWarnings("unchecked")
protected Map processResultSet(ResultSet rs, ResultSetSupportingSqlParameter param) throws SQLException {
    if (rs == null) {
        return Collections.EMPTY_MAP;
    }
    Map returnedResults = new HashMap();
    try {
        ResultSet rsToUse = rs;
        if (this.nativeJdbcExtractor != null) {
            rsToUse = this.nativeJdbcExtractor.getNativeResultSet(rs);
        }
        if (param.getRowMapper() != null) {
            RowMapper rowMapper = param.getRowMapper();
            Object result = (new RowMapperResultSetExtractor(rowMapper)).extractData(rsToUse);
            returnedResults.put(param.getName(), result);
        } else if (param.getRowCallbackHandler() != null) {
            RowCallbackHandler rch = param.getRowCallbackHandler();
            (new RowCallbackHandlerResultSetExtractor(rch)).extractData(rsToUse);
            returnedResults.put(param.getName(), "ResultSet returned from stored procedure was processed");
        } else if (param.getResultSetExtractor() != null) {
            Object result = param.getResultSetExtractor().extractData(rsToUse);
            returnedResults.put(param.getName(), result);
        }
    } finally {
        JdbcUtils.closeResultSet(rs);
    }
    return returnedResults;
}

From source file:org.springframework.jdbc.core.JdbcTemplate.java

/**
 * Process the given ResultSet from a stored procedure.
 * @param rs the ResultSet to process// w ww.j  av  a 2s  .  c  o  m
 * @param param the corresponding stored procedure parameter
 * @return Map that contains returned results
 */
protected Map processResultSet(ResultSet rs, ResultSetSupportingSqlParameter param) throws SQLException {
    Map returnedResults = new HashMap();
    try {
        ResultSet rsToUse = rs;
        if (this.nativeJdbcExtractor != null) {
            rsToUse = this.nativeJdbcExtractor.getNativeResultSet(rs);
        }
        if (param.isRowCallbackHandlerSupported()) {
            // It's a RowCallbackHandler or RowMapper.
            // We'll get a RowCallbackHandler to use in both cases.
            RowCallbackHandler rch = param.getRowCallbackHandler();
            (new RowCallbackHandlerResultSetExtractor(rch)).extractData(rsToUse);
            if (rch instanceof ResultReader) {
                returnedResults.put(param.getName(), ((ResultReader) rch).getResults());
            } else {
                returnedResults.put(param.getName(), "ResultSet returned from stored procedure was processed.");
            }
        } else {
            // It's a ResultSetExtractor - simply apply it.
            Object result = param.getResultSetExtractor().extractData(rsToUse);
            returnedResults.put(param.getName(), result);
        }
    } finally {
        JdbcUtils.closeResultSet(rs);
    }
    return returnedResults;
}