{
// Need to ensure all the result sets opened by this
// CALL statement for this connection are closed.
// If any close() results in an exception we need to keep going,
// save any exceptions and then throw them once we are complete.
StandardException errorOnClose = null;
ConnectionContext jdbcContext = null;
for (int i = 0; i < dynamicResults.length; i++)
{
ResultSet[] param = dynamicResults[i];
ResultSet drs = param[0];
// Can be null if the procedure never set this parameter
// or if the dynamic results were processed by JDBC (EmbedStatement).
if (drs == null)
continue;
if (jdbcContext == null)
jdbcContext = (ConnectionContext)
lcc.getContextManager().getContext(ConnectionContext.CONTEXT_ID);
try {
// Is this a valid, open dynamic result set for this connection?
if (!jdbcContext.processInaccessibleDynamicResult(drs))
{
// If not just ignore it, not Derby's problem.
continue;
}
drs.close();
} catch (SQLException e) {
// Just report the first error
if (errorOnClose == null)
{
StandardException se = StandardException.plainWrapException(e);
errorOnClose = se;
}
}
finally {
// Remove any reference to the ResultSet to allow