Package: groovy.sql

## [Java] Class Sql.AbstractQueryCommand

- groovy.sql.Sql.AbstractQueryCommand

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected String` | `sql` |
    `protected Statement` | `statement` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `protected AbstractQueryCommand (String sql)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected void` | `closeResources()` After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.
    `` | `protected void` | `closeResources(ResultSet rs)` After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.
    `` | `protected ResultSet` | `execute()` Execute the command that's defined by the subclass following the Command pattern.
    `` | `protected int` | `getMaxRows()` Get the maximum number of rows to return in the ResultSet
    `` | `protected ResultSet` | `runQuery(Connection connection)` Perform the query.
    `` | `protected void` | `setMaxRows(int maxRows)` Set the maximum number of rows to return in the ResultSet

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### protected final String sql

    - #### protected Statement statement

  - ### Constructor Detail

    - #### protected AbstractQueryCommand(String sql)

  - ### Method Detail

    - #### protected final void closeResources()

      After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.

    - #### protected final void closeResources(ResultSet rs)

      After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.

      Parameters:
        `rs` - allows the caller to conveniently close its resource as well

    - #### protected final ResultSet execute()

      Execute the command that's defined by the subclass following the Command pattern. Specialized parameters are held in the command instances.

      throws:
        SQLException if a database error occurs
      Returns:
        ResultSet from executing a query

    - #### protected int getMaxRows()

      Get the maximum number of rows to return in the ResultSet

      Returns:
        the maximum number of rows

    - #### protected ResultSet runQuery(Connection connection)

      Perform the query. Must set statement field so that the main (execute()) method can clean up. This is the method that encloses the variant part of the code.

      throws:
        SQLException if a database error occurs
      Parameters:
        `connection` - the connection to use
      Returns:
        ResultSet from an executeQuery method.

    - #### protected void setMaxRows(int maxRows)

      Set the maximum number of rows to return in the ResultSet

      Parameters:
        `maxRows` - the maximum number of rows