Top Description Fields Constructors Methods
org.h2.command

public abstract Class Command

extends Object
implements CommandInterface
Class Inheritance
All Implemented Interfaces
org.h2.command.CommandInterface, java.lang.AutoCloseable
Known Direct Subclasses
org.h2.command.CommandContainer, org.h2.command.CommandList
Imports
java.sql.SQLException, .Statement, java.util.ArrayList, .Set, org.h2.api.ErrorCode, org.h2.engine.Constants, .Database, .DbObject, .Mode.CharPadding, .Session, .SessionLocal, org.h2.expression.ParameterInterface, org.h2.message.DbException, .Trace, org.h2.result.BatchResult, .MergedResult, .ResultInterface, .ResultWithGeneratedKeys, .ResultWithPaddedStrings, org.h2.util.Utils, org.h2.value.Value

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

Field Summary

Modifier and TypeField and Description
private volatile boolean
cancel

If this query was canceled.

private boolean
protected final SessionLocal
session

The session.

private final String
protected long
startTimeNanos

The last start time.

private final Trace
trace

The trace module.

Constructor Summary

AccessConstructor and Description
pack-priv
Command(SessionLocal session, String sql)

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Implements org.h2.command.CommandInterface.cancel.

Cancel the statement if it is still processing.

public boolean

Returns:

true if it can be re-used
canReuse
()

Whether the command is already closed (in which case it can be re-used).

protected void
checkCanceled()

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

public void
close()

Implements org.h2.command.CommandInterface.close.

Close the statement.

private void
public BatchResult
executeBatchUpdate(ArrayList<Value[]>
batch parameters
batchParameters
,
Object
null or false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from
generatedKeysRequest
)

Implements org.h2.command.CommandInterface.executeBatchUpdate.

Executes the statement with multiple sets of parameters.

public ResultInterface

Returns:

the result set
executeQuery
(long
the maximum number of rows to return
maxrows
,
boolean
if the result set must be scrollable (ignored)
scrollable
)

Implements org.h2.command.CommandInterface.executeQuery.

Execute a query and return the result.

public ResultWithGeneratedKeys
executeUpdate(Object
null or false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from
generatedKeysRequest
)

Implements org.h2.command.CommandInterface.executeUpdate.

Execute the statement

private ResultWithGeneratedKeys
executeUpdate(Object generatedKeysRequest, boolean commitIfAutoCommit)

private long
protected final Database
public abstract Set<DbObject>
public final ResultInterface
getMetaData()

Implements org.h2.command.CommandInterface.getMetaData.

Get an empty result set containing the meta data of the result.

public abstract ArrayList<? extends ParameterInterface>

Returns:

the list of parameters
getParameters
()

Redeclares org.h2.command.CommandInterface.getParameters.

Get the list of parameters.

public boolean
public abstract boolean

Returns:

true if it is
isQuery
()

Redeclares org.h2.command.CommandInterface.isQuery.

Check if this command is a query.

public abstract boolean

Returns:

true if it is
isReadOnly
()

Check if this command is read only.

protected abstract boolean

Returns:

is this command can be repeated again on locking failure
isRetryable
()

Returns is this command can be repeated again on locking failure.

public abstract boolean

Returns:

true if it is
isTransactional
()

Check if this command is transactional.

public abstract ResultInterface

Returns:

the local result set
query
(long
the maximum number of rows returned
maxrows
)

Execute a query statement, if this is possible.

public abstract ResultInterface

Returns:

an empty result set
queryMeta
()

Get an empty result set containing the meta data.

public void
reuse()

The command is now re-used, therefore reset the canReuse flag, and the parameter values.

public void
setCanReuse(boolean canReuse)

pack-priv void
setProgress(Database database, int state)

pack-priv void
start()

Start the stopwatch.

public void
stop(boolean
commit the session if auto-commit is enabled
commitIfAutoCommit
)

Implements org.h2.command.CommandInterface.stop.

Stop the command execution, release all locks and resources.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public abstract ResultWithGeneratedKeys

Returns:

the update count and generated keys, if any
update
(Object
false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from
generatedKeysRequest
)

Execute an updating statement (for example insert, delete, or update), if this is possible.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cancelback to summary
private volatile boolean cancel

If this query was canceled.

canReuseback to summary
private boolean canReuse
sessionback to summary
protected final SessionLocal session

The session.

sqlback to summary
private final String sql
startTimeNanosback to summary
protected long startTimeNanos

The last start time.

traceback to summary
private final Trace trace

The trace module.

Constructor Detail

Commandback to summary
pack-priv Command(SessionLocal session, String sql)

Method Detail

cancelback to summary
public void cancel()

Implements org.h2.command.CommandInterface.cancel.

Doc from org.h2.command.CommandInterface.cancel.

Cancel the statement if it is still processing.

Annotations
@Override
canReuseback to summary
public boolean canReuse()

Whether the command is already closed (in which case it can be re-used).

Returns:boolean

true if it can be re-used

checkCanceledback to summary
protected void checkCanceled()

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

Exceptions
DbException:
if the statement has been canceled
closeback to summary
public void close()

Implements org.h2.command.CommandInterface.close.

Doc from org.h2.command.CommandInterface.close.

Close the statement.

Annotations
@Override
commitIfNonTransactionalback to summary
private void commitIfNonTransactional()
executeBatchUpdateback to summary
public BatchResult executeBatchUpdate(ArrayList<Value[]> batchParameters, Object generatedKeysRequest)

Implements org.h2.command.CommandInterface.executeBatchUpdate.

Doc from org.h2.command.CommandInterface.executeBatchUpdate.

Executes the statement with multiple sets of parameters.

Parameters
batchParameters:ArrayList<Value[]>

batch parameters

generatedKeysRequest:Object

null or false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from

Returns:BatchResult

result of batch execution

Annotations
@Override
executeQueryback to summary
public ResultInterface executeQuery(long maxrows, boolean scrollable)

Implements org.h2.command.CommandInterface.executeQuery.

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

Parameters
maxrows:long

the maximum number of rows to return

scrollable:boolean

if the result set must be scrollable (ignored)

Returns:ResultInterface

the result set

Annotations
@Override
executeUpdateback to summary
public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest)

Implements org.h2.command.CommandInterface.executeUpdate.

Doc from org.h2.command.CommandInterface.executeUpdate.

Execute the statement

Parameters
generatedKeysRequest:Object

null or false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from

Returns:ResultWithGeneratedKeys

the update count and generated keys, if any

Annotations
@Override
executeUpdateback to summary
private ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest, boolean commitIfAutoCommit)
filterConcurrentUpdateback to summary
private long filterConcurrentUpdate(DbException e, long start)
getDatabaseback to summary
protected final Database getDatabase()
getDependenciesback to summary
public abstract Set<DbObject> getDependencies()
getMetaDataback to summary
public final ResultInterface getMetaData()

Implements org.h2.command.CommandInterface.getMetaData.

Doc from org.h2.command.CommandInterface.getMetaData.

Get an empty result set containing the meta data of the result.

Returns:ResultInterface

the empty result

Annotations
@Override
getParametersback to summary
public abstract ArrayList<? extends ParameterInterface> getParameters()

Redeclares org.h2.command.CommandInterface.getParameters.

Get the list of parameters.

Returns:ArrayList<? extends ParameterInterface>

the list of parameters

Annotations
@Override
isCacheableback to summary
public boolean isCacheable()
isQueryback to summary
public abstract boolean isQuery()

Redeclares org.h2.command.CommandInterface.isQuery.

Check if this command is a query.

Returns:boolean

true if it is

Annotations
@Override
isReadOnlyback to summary
public abstract boolean isReadOnly()

Check if this command is read only.

Returns:boolean

true if it is

isRetryableback to summary
protected abstract boolean isRetryable()

Returns is this command can be repeated again on locking failure.

Returns:boolean

is this command can be repeated again on locking failure

isTransactionalback to summary
public abstract boolean isTransactional()

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

Returns:boolean

true if it is

queryback to summary
public abstract ResultInterface query(long maxrows)

Execute a query statement, if this is possible.

Parameters
maxrows:long

the maximum number of rows returned

Returns:ResultInterface

the local result set

Exceptions
DbException:
if the command is not a query
queryMetaback to summary
public abstract ResultInterface queryMeta()

Get an empty result set containing the meta data.

Returns:ResultInterface

an empty result set

reuseback to summary
public void reuse()

The command is now re-used, therefore reset the canReuse flag, and the parameter values.

setCanReuseback to summary
public void setCanReuse(boolean canReuse)
setProgressback to summary
pack-priv void setProgress(Database database, int state)
startback to summary
pack-priv void start()

Start the stopwatch.

stopback to summary
public void stop(boolean commitIfAutoCommit)

Implements org.h2.command.CommandInterface.stop.

Doc from org.h2.command.CommandInterface.stop.

Stop the command execution, release all locks and resources.

Parameters
commitIfAutoCommit:boolean

commit the session if auto-commit is enabled

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
updateback to summary
public abstract ResultWithGeneratedKeys update(Object generatedKeysRequest)

Execute an updating statement (for example insert, delete, or update), if this is possible.

Parameters
generatedKeysRequest:Object

false if generated keys are not needed, true if generated keys should be configured automatically, int[] to specify column indices to return generated keys from, or String[] to specify column names to return generated keys from

Returns:ResultWithGeneratedKeys

the update count and generated keys, if any

Exceptions
DbException:
if the command is not an updating statement