| java.lang.Object workbench.sql.SqlCommand
All known Subclasses: workbench.sql.wbcommands.WbCall, workbench.sql.wbcommands.WbListProcedures, workbench.sql.wbcommands.WbStartBatch, workbench.sql.wbcommands.WbListVars, workbench.sql.wbcommands.WbSchemaReport, workbench.sql.wbcommands.WbConnect, workbench.sql.wbcommands.WbDefinePk, workbench.sql.wbcommands.WbDefineVar, workbench.sql.wbcommands.WbFeedback, workbench.sql.wbcommands.WbEnableOraOutput, workbench.sql.wbcommands.WbEndBatch, workbench.sql.wbcommands.WbSavePkMapping, workbench.sql.wbcommands.WbInclude, workbench.sql.wbcommands.WbListTables, workbench.sql.wbcommands.WbSchemaDiff, workbench.sql.wbcommands.WbDisableOraOutput, workbench.sql.wbcommands.WbListPkDef, workbench.sql.commands.SingleVerbCommand, workbench.sql.wbcommands.WbConfirm, workbench.sql.commands.UpdatingCommand, workbench.sql.wbcommands.WbCopy, workbench.sql.wbcommands.WbXslt, workbench.sql.commands.UseCommand, workbench.sql.wbcommands.WbRemoveVar, workbench.sql.commands.IgnoredCommand, workbench.sql.commands.SetCommand, workbench.sql.wbcommands.WbLoadPkMapping, workbench.sql.commands.DdlCommand, workbench.sql.wbcommands.WbDescribeTable, workbench.sql.wbcommands.WbListCatalogs, workbench.sql.commands.SelectCommand, workbench.sql.wbcommands.WbExport, workbench.sql.wbcommands.WbSelectBlob, workbench.sql.commands.AlterSessionCommand, workbench.sql.wbcommands.WbImport,
SqlCommand | public class SqlCommand (Code) | | A single SQL command. This class is used if no special class was found
for a given SQL verb. The execute method checks if the command
returned a result set or simply an update count.
An instance of a SQL command should always be executed in a separate Thread
to allow cancelling of the running statement.
author: support@sql-workbench.net |
Method Summary | |
protected void | addErrorInfo(StatementRunnerResult result, String sql, Throwable e) | protected void | appendOutput(StatementRunnerResult result) | protected void | appendSuccessMessage(StatementRunnerResult result) | protected boolean | appendWarnings(StatementRunnerResult result) Append any warnings from the given Statement and Connection to the given
StringBuilder. | public void | cancel() Cancels this statements execution. | public void | consumeResult(StatementRunnerResult aResult) | public void | done() This method should be called, once the caller is finished with running
the SQL command. | protected WbFile | evaluateFileArgument(String fileName) | public StatementRunnerResult | execute(String aSql) Should be overridden by a specialised SqlCommand. | public ArgumentParser | getArgumentParser() | protected String | getCommandLine(String sql) | public boolean | getFullErrorReporting() | public String | getVerb() | protected boolean | isConnectionRequired() | public boolean | isConsumerWaiting() | protected boolean | isMultiple(String sql) Check if the passed SQL is a "batched" statement.
Returns true if the passed SQL string could be a "batched"
statement that actually contains more than one statement.
SQL Server supports these kind of "batches". | public boolean | isResultSetConsumer() | public boolean | isUpdatingCommand() | protected void | processMoreResults(String sql, StatementRunnerResult result, boolean hasResult) Tries to process any "pending" results from the last statement that was
executed, but only if the current DBMS supports multiple SQL statements
in a single execute() call. | protected void | processResults(StatementRunnerResult result, boolean hasResult) | protected void | processResults(StatementRunnerResult result, boolean hasResult, ResultSet queryResult) Process any ResultSets or updatecounts generated by the last statement
execution. | public void | setConnection(WbConnection conn) | public void | setConsumerWaiting(boolean flag) The commands producing a result set need this flag. | public void | setFullErrorReporting(boolean flag) | public void | setMaxRows(int max) | public void | setParameterPrompter(ParameterPrompter p) | public void | setQueryTimeout(int timeout) | public void | setResultLogger(ResultLogger logger) | public void | setRowMonitor(RowActionMonitor monitor) | public void | setStatementRunner(StatementRunner r) | protected void | setUnknownMessage(StatementRunnerResult result, ArgumentParser cmdline, String help) |
isCancelled | protected boolean isCancelled(Code) | | |
isUpdatingCommand | protected boolean isUpdatingCommand(Code) | | |
maxRows | protected int maxRows(Code) | | |
queryTimeout | protected int queryTimeout(Code) | | |
reportFullStatementOnError | protected boolean reportFullStatementOnError(Code) | | |
SqlCommand | public SqlCommand()(Code) | | |
appendWarnings | protected boolean appendWarnings(StatementRunnerResult result)(Code) | | Append any warnings from the given Statement and Connection to the given
StringBuilder. If the connection is a connection to Oracle
then any messages written with dbms_output are appended as well
This behaviour is then similar to MS SQL Server where any messages
displayed using the PRINT function are returned in the Warnings as well.
See Also: workbench.util.SqlUtil.getWarnings(WbConnectionStatement) |
cancel | public void cancel() throws SQLException(Code) | | Cancels this statements execution. Cancelling is done by
calling cancel on the current JDBC Statement object. This requires
that the JDBC driver actually supports cancelling of statements and
that this method is called from a differen thread.
It also sets the internal cancelled flag so that SqlCommands
that process data in a loop can check this flag and exit the loop
(e.g.
workbench.sql.wbcommands.WbExport )
|
done | public void done()(Code) | | This method should be called, once the caller is finished with running
the SQL command. This releases any database resources that were
obtained during the execution of the statement (especially it
closes the JDBC statement object that was used to run this command).
If this statement has been cancelled a rollback() is sent to the server.
|
getCommandLine | protected String getCommandLine(String sql)(Code) | | Get a "clean" version of the sql with the verb stripped off
and all comments and newlines removed for processing the
parameters to a Workbench command
Parameters: sql - the sql to "clean" the sql with the verb, comments and newlines removed See Also: workbench.util.Sqlutil.makeCleanSql(Stringbooleanbooleanchar) See Also: workbench.util.Sqlutil.getVerb(String) |
getFullErrorReporting | public boolean getFullErrorReporting()(Code) | | |
getVerb | public String getVerb()(Code) | | Should be overridden by a specialised SqlCommand
|
isConnectionRequired | protected boolean isConnectionRequired()(Code) | | |
isConsumerWaiting | public boolean isConsumerWaiting()(Code) | | |
isMultiple | protected boolean isMultiple(String sql)(Code) | | Check if the passed SQL is a "batched" statement.
Returns true if the passed SQL string could be a "batched"
statement that actually contains more than one statement.
SQL Server supports these kind of "batches". If this is the case
affected rows will always be shown, because we cannot know
if the statement did not update anything or if it actually
updated only 0 rows (for some reason SQL Server seems to
return 0 as the updatecount even if no update was involved).
Currently this is only checking for newlines in the passed string.
Parameters: sql - the statement/script to check true if the passed sql could contain more than one (independent) statements |
isResultSetConsumer | public boolean isResultSetConsumer()(Code) | | |
isUpdatingCommand | public boolean isUpdatingCommand()(Code) | | |
setConsumerWaiting | public void setConsumerWaiting(boolean flag)(Code) | | The commands producing a result set need this flag.
If no consumer is waiting, the can directly produce a DataStore
for the result.
|
setFullErrorReporting | public void setFullErrorReporting(boolean flag)(Code) | | |
setMaxRows | public void setMaxRows(int max)(Code) | | |
setQueryTimeout | public void setQueryTimeout(int timeout)(Code) | | |
|
|