* @param maxResults - the maximum number of results to return
* @param callback - a row handler for processing the results
* @throws SQLException - if the procedure fails
*/
public void executeQueryProcedure(RequestScope request, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
ErrorContext errorContext = request.getErrorContext();
errorContext.setActivity("executing query procedure");
errorContext.setObjectId(sql);
CallableStatement cs = null;
ResultSet rs = null;
try {
errorContext.setMoreInfo("Check the SQL Statement (preparation failed).");
Integer rsType = request.getStatement().getResultSetType();
if (rsType != null) {
cs = conn.prepareCall(sql, rsType.intValue(), ResultSet.CONCUR_READ_ONLY);
} else {
cs = conn.prepareCall(sql);
}
setStatementTimeout(request.getStatement(), cs);
Integer fetchSize = request.getStatement().getFetchSize();
if (fetchSize != null) {
cs.setFetchSize(fetchSize.intValue());
}
ParameterMap parameterMap = request.getParameterMap();
ParameterMapping[] mappings = parameterMap.getParameterMappings();
errorContext.setMoreInfo("Check the output parameters (register output parameters failed).");
registerOutputParameters(cs, mappings);
errorContext.setMoreInfo("Check the parameters (set parameters failed).");
parameterMap.setParameters(request, cs, parameters);
errorContext.setMoreInfo("Check the statement (update procedure failed).");
cs.execute();
errorContext.setMoreInfo("Check the results (failed to retrieve results).");
// Begin ResultSet Handling
rs = handleMultipleResults(cs, request, skipResults, maxResults, callback);
// End ResultSet Handling
errorContext.setMoreInfo("Check the output parameters (retrieval of output parameters failed).");
retrieveOutputParameters(request, cs, mappings, parameters, callback);
} finally {
try {
closeResultSet(rs);