org.h2.command
Class Command

java.lang.Object
  extended by 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 the query.
 LocalResult executeQueryLocal(int maxrows)
          Execute a query and return a local result set.
 int executeUpdate()
          Execute the statement
 ResultInterface getMetaData()
          Get an empty result set containing the meta data of the result.
 LocalResult getMetaDataLocal()
           
abstract  ObjectArray<? extends ParameterInterface> getParameters()
          Get the list of parameters.
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.
 LocalResult query(int maxrows)
          Execute a query statement, if this is possible.
abstract  LocalResult 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 ObjectArray<? 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 LocalResult queryMeta()
                               throws java.sql.SQLException
Get an empty result set containing the meta data.

Returns:
an empty result set
Throws:
java.sql.SQLException

update

public int update()
           throws java.sql.SQLException
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 LocalResult query(int maxrows)
                  throws java.sql.SQLException
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

getMetaDataLocal

public final LocalResult getMetaDataLocal()
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getMetaData

public final ResultInterface getMetaData()
                                  throws java.sql.SQLException
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
Throws:
java.sql.SQLException

executeQuery

public ResultInterface executeQuery(int maxrows,
                                    boolean scrollable)
                             throws java.sql.SQLException
Description copied from interface: CommandInterface
Execute the query.

Specified by:
executeQuery in interface CommandInterface
Parameters:
maxrows - the maximum number of rows returned
scrollable - if the result set must be scrollable
Returns:
the result
Throws:
java.sql.SQLException

executeQueryLocal

public LocalResult executeQueryLocal(int maxrows)
                              throws java.sql.SQLException
Execute a query and return a local result set. This method prepares everything and calls query(int) finally.

Parameters:
maxrows - the maximum number of rows to return
Returns:
the local result set
Throws:
java.sql.SQLException

checkCanceled

public void checkCanceled()
                   throws java.sql.SQLException
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()
                  throws java.sql.SQLException
Description copied from interface: CommandInterface
Execute the statement

Specified by:
executeUpdate in interface CommandInterface
Returns:
the update count
Throws:
java.sql.SQLException

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