Java Doc for SqlCommand.java in  » Database-Client » SQL-Workbench » workbench » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » SQL Workbench » workbench.sql 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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


Field Summary
protected  ArgumentParsercmdLine
    
protected  WbConnectioncurrentConnection
    
protected  DataStorecurrentRetrievalData
    
protected  StatementcurrentStatement
    
protected  booleanisCancelled
    
protected  booleanisUpdatingCommand
    
protected  intmaxRows
    
protected  ParameterPrompterprompter
    
protected  intqueryTimeout
    
protected  booleanreportFullStatementOnError
    
protected  ResultLoggerresultLogger
    
protected  RowActionMonitorrowMonitor
    
protected  StatementRunnerrunner
    

Constructor Summary
public  SqlCommand()
    

Method Summary
protected  voidaddErrorInfo(StatementRunnerResult result, String sql, Throwable e)
    
protected  voidappendOutput(StatementRunnerResult result)
    
protected  voidappendSuccessMessage(StatementRunnerResult result)
    
protected  booleanappendWarnings(StatementRunnerResult result)
     Append any warnings from the given Statement and Connection to the given StringBuilder.
public  voidcancel()
     Cancels this statements execution.
public  voidconsumeResult(StatementRunnerResult aResult)
    
public  voiddone()
     This method should be called, once the caller is finished with running the SQL command.
protected  WbFileevaluateFileArgument(String fileName)
    
public  StatementRunnerResultexecute(String aSql)
     Should be overridden by a specialised SqlCommand.
public  ArgumentParsergetArgumentParser()
    
protected  StringgetCommandLine(String sql)
    
public  booleangetFullErrorReporting()
    
public  StringgetVerb()
    
protected  booleanisConnectionRequired()
    
public  booleanisConsumerWaiting()
    
protected  booleanisMultiple(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  booleanisResultSetConsumer()
    
public  booleanisUpdatingCommand()
    
protected  voidprocessMoreResults(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  voidprocessResults(StatementRunnerResult result, boolean hasResult)
    
protected  voidprocessResults(StatementRunnerResult result, boolean hasResult, ResultSet queryResult)
     Process any ResultSets or updatecounts generated by the last statement execution.
public  voidsetConnection(WbConnection conn)
    
public  voidsetConsumerWaiting(boolean flag)
     The commands producing a result set need this flag.
public  voidsetFullErrorReporting(boolean flag)
    
public  voidsetMaxRows(int max)
    
public  voidsetParameterPrompter(ParameterPrompter p)
    
public  voidsetQueryTimeout(int timeout)
    
public  voidsetResultLogger(ResultLogger logger)
    
public  voidsetRowMonitor(RowActionMonitor monitor)
    
public  voidsetStatementRunner(StatementRunner r)
    
protected  voidsetUnknownMessage(StatementRunnerResult result, ArgumentParser cmdline, String help)
    

Field Detail
cmdLine
protected ArgumentParser cmdLine(Code)



currentConnection
protected WbConnection currentConnection(Code)



currentRetrievalData
protected DataStore currentRetrievalData(Code)



currentStatement
protected Statement currentStatement(Code)



isCancelled
protected boolean isCancelled(Code)



isUpdatingCommand
protected boolean isUpdatingCommand(Code)



maxRows
protected int maxRows(Code)



prompter
protected ParameterPrompter prompter(Code)



queryTimeout
protected int queryTimeout(Code)



reportFullStatementOnError
protected boolean reportFullStatementOnError(Code)



resultLogger
protected ResultLogger resultLogger(Code)



rowMonitor
protected RowActionMonitor rowMonitor(Code)



runner
protected StatementRunner runner(Code)




Constructor Detail
SqlCommand
public SqlCommand()(Code)




Method Detail
addErrorInfo
protected void addErrorInfo(StatementRunnerResult result, String sql, Throwable e)(Code)



appendOutput
protected void appendOutput(StatementRunnerResult result)(Code)



appendSuccessMessage
protected void appendSuccessMessage(StatementRunnerResult result)(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 )



consumeResult
public void consumeResult(StatementRunnerResult aResult)(Code)



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.



evaluateFileArgument
protected WbFile evaluateFileArgument(String fileName)(Code)



execute
public StatementRunnerResult execute(String aSql) throws SQLException, Exception(Code)
Should be overridden by a specialised SqlCommand. setConnection should have been called before calling execute()



getArgumentParser
public ArgumentParser getArgumentParser()(Code)



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)



processMoreResults
protected void processMoreResults(String sql, StatementRunnerResult result, boolean hasResult) throws SQLException(Code)
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. In all other cases the current SqlCommand will process results properly. If the DBMS does not support "batched" statements, then only possible warnings are stored in the result object
See Also:   SqlCommand.processResults(StatementRunnerResult,boolean)
See Also:   SqlCommand.appendWarnings(StatementRunnerResult)



processResults
protected void processResults(StatementRunnerResult result, boolean hasResult) throws SQLException(Code)



processResults
protected void processResults(StatementRunnerResult result, boolean hasResult, ResultSet queryResult) throws SQLException(Code)
Process any ResultSets or updatecounts generated by the last statement execution.



setConnection
public void setConnection(WbConnection conn)(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)



setParameterPrompter
public void setParameterPrompter(ParameterPrompter p)(Code)



setQueryTimeout
public void setQueryTimeout(int timeout)(Code)



setResultLogger
public void setResultLogger(ResultLogger logger)(Code)



setRowMonitor
public void setRowMonitor(RowActionMonitor monitor)(Code)



setStatementRunner
public void setStatementRunner(StatementRunner r)(Code)



setUnknownMessage
protected void setUnknownMessage(StatementRunnerResult result, ArgumentParser cmdline, String help)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.