## org.h2.command
Class Command

    java.lang.Object
      org.h2.command.Command

All Implemented Interfaces:
  CommandInterface

Direct Known Subclasses:
  CommandContainer, CommandList

    public abstract class Command

extends java.lang.Object
implements CommandInterface

Represents a SQL statement. This object is only used on the server side.

Field Summary
`protected Session` `session` The session.
`protected long` `startTime` The last start time.
`protected Trace` `trace` The trace module.

Constructor Summary
`Command(Parser parser, java.lang.String sql)`

Method Summary
`void` `cancel()` Cancel the statement if it is still processing.
`void` `checkCanceled()` Check if this command has been canceled, and throw an exception if yes.
`void` `close()` Close the statement.
`ResultInterface` `executeQuery(int maxrows, boolean scrollable)` Execute a query and return the result.
`int` `executeUpdate()` Execute the statement
`ResultInterface` `getMetaData()` Get an empty result set containing the meta data of the result.
`abstract java.util.ArrayList<? extends ParameterInterface>` `getParameters()` Get the list of parameters.
`boolean` `isCacheable()`
`abstract boolean` `isQuery()` Check if this command is a query.
`abstract boolean` `isReadOnly()` Check if this command is read only.
`abstract boolean` `isTransactional()` Check if this command is transactional.
`ResultInterface` `query(int maxrows)` Execute a query statement, if this is possible.
`abstract ResultInterface` `queryMeta()` Get an empty result set containing the meta data.
`java.lang.String` `toString()`
`int` `update()` Execute an updating statement, if this is possible.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### session

    protected final Session session

  The session.

### trace

    protected final Trace trace

  The trace module.

### startTime

    protected long startTime

  The last start time.

Constructor Detail

### Command

    public Command(Parser parser,
                   java.lang.String sql)

Method Detail

### isTransactional

    public abstract boolean isTransactional()

  Check if this command is transactional. If it is not, then it forces the current transaction to commit.

  Returns:
    true if it is

### isQuery

    public abstract boolean isQuery()

  Check if this command is a query.

  Specified by:
    `isQuery` in interface `CommandInterface`
  Returns:
    true if it is

### getParameters

    public abstract java.util.ArrayList<? extends ParameterInterface> getParameters()

  Get the list of parameters.

  Specified by:
    `getParameters` in interface `CommandInterface`
  Returns:
    the list of parameters

### isReadOnly

    public abstract boolean isReadOnly()

  Check if this command is read only.

  Returns:
    true if it is

### queryMeta

    public abstract ResultInterface queryMeta()

  Get an empty result set containing the meta data.

  Returns:
    an empty result set

### update

    public int update()

  Execute an updating statement, if this is possible.

  Returns:
    the update count
  Throws:
    `java.sql.SQLException` - if the command is not an updating statement

### query

    public ResultInterface query(int maxrows)

  Execute a query statement, if this is possible.

  Parameters:
    `maxrows` - the maximum number of rows returned
  Returns:
    the local result set
  Throws:
    `java.sql.SQLException` - if the command is not a query

### getMetaData

    public final ResultInterface getMetaData()

  Description copied from interface: `CommandInterface`
  Get an empty result set containing the meta data of the result.

  Specified by:
    `getMetaData` in interface `CommandInterface`
  Returns:
    the empty result

### executeQuery

    public ResultInterface executeQuery(int maxrows,
                                        boolean scrollable)

  Execute a query and return the result. This method prepares everything and calls `query(int)` finally.

  Specified by:
    `executeQuery` in interface `CommandInterface`
  Parameters:
    `maxrows` - the maximum number of rows to return
    `scrollable` - if the result set must be scrollable (ignored)
  Returns:
    the result set

### checkCanceled

    public void checkCanceled()

  Check if this command has been canceled, and throw an exception if yes.

  Throws:
    `java.sql.SQLException` - if the statement has been canceled

### executeUpdate

    public int executeUpdate()

  Description copied from interface: `CommandInterface`
  Execute the statement

  Specified by:
    `executeUpdate` in interface `CommandInterface`
  Returns:
    the update count

### close

    public void close()

  Description copied from interface: `CommandInterface`
  Close the statement.

  Specified by:
    `close` in interface `CommandInterface`

### cancel

    public void cancel()

  Description copied from interface: `CommandInterface`
  Cancel the statement if it is still processing.

  Specified by:
    `cancel` in interface `CommandInterface`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### isCacheable

    public boolean isCacheable()