public void execute(String sql,List<Object> params,Closure processResults) throws SQLException {
  Connection connection=createConnection();
  PreparedStatement statement=null;
  try {
    statement=getPreparedStatement(connection,sql,params);
    boolean isResultSet=statement.execute();
    int updateCount=statement.getUpdateCount();
    while (isResultSet || updateCount != -1) {
      if (processResults.getMaximumNumberOfParameters() != 2) {
        throw new SQLException("Incorrect number of parameters for processResults Closure");
      }
      if (isResultSet) {
        ResultSet resultSet=statement.getResultSet();
        List<GroovyRowResult> rowResult=resultSet == null ? null : asList(sql,resultSet);
        processResults.call(isResultSet,rowResult);
      }
 else {
        processResults.call(isResultSet,updateCount);
      }
      isResultSet=statement.getMoreResults();
      updateCount=statement.getUpdateCount();
    }
  }
 catch (  SQLException e) {
    LOG.warning("Failed to execute: " + sql + " because: "+ e.getMessage());
    throw e;
  }
 finally {
    closeResources(connection,statement);
  }
}

public void execute ( String sql , List < Object > params , Closure processResults ) throws SQLException { Connection connection = createConnection ( ) ; PreparedStatement statement = null ; try { statement = getPreparedStatement ( connection , sql , params ) ; boolean isResultSet = statement . execute ( ) ; int updateCount = statement . getUpdateCount ( ) ; while ( isResultSet || updateCount != - 1 ) { if ( processResults . getMaximumNumberOfParameters ( ) != 2 ) { throw new SQLException ( "Incorrect number of parameters for processResults Closure" ) ; } if ( isResultSet ) { ResultSet resultSet = statement . getResultSet ( ) ; List < GroovyRowResult > rowResult = resultSet == null ? null : asList ( sql , resultSet ) ; processResults . call ( isResultSet , rowResult ) ; } else { processResults . call ( isResultSet , updateCount ) ; } isResultSet = statement . getMoreResults ( ) ; updateCount = statement . getUpdateCount ( ) ; } } catch ( SQLException e ) { LOG . warning ( "Failed to execute: " + sql + " because: " + e . getMessage ( ) ) ; throw e ; } finally { closeResources ( connection , statement ) ; } }
executes the given piece of sql with parameters . also calls the provided processresults closure to process any resultset or updatecount results that executing the sql might produce . < p > this method supports named and named ordinal parameters . see the class javadoc for more details . < p > resource handling is performed automatically where appropriate .
