|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.jdbc.WrapperImpl
com.metamatrix.jdbc.MMStatement
public class MMStatement
This object is used to execute queries and updates against the MetaMatrix server. This object submits queries to MetaMatrix server by sending request messages. The query execution gives a MMXResultSet object that can be used to navigate the results. An update can be executed to return the number of rows affected. The MMXStatement object can be used by multiple threads, the MMXResultSet objects for each object is added to a hashtable so that we could have a ResultSet object open for each executing thread. When the statement object is closed all the ResultSet objects on any given statement are closed.
Field Summary | |
---|---|
protected static int |
CANCELLED
|
protected int |
commandStatus
|
protected long |
currentRequestID
|
protected static int |
NO_TIMEOUT
|
protected java.util.Map |
outParamIndexMap
|
protected int |
queryTimeout
|
protected MMResultSet |
resultSet
|
protected static int |
TIMED_OUT
|
protected int[] |
updateCounts
Array of update counts as returned by executeBatch() |
Fields inherited from interface java.sql.Statement |
---|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
Method Summary | |
---|---|
protected void |
accumulateWarnings(java.util.List<java.lang.Exception> serverWarnings)
|
void |
addBatch(java.lang.String sql)
Adds sql to this statement object's current list of commands. |
void |
attachStylesheet(java.io.Reader reader)
This method sets a style sheet to this object. |
void |
cancel()
This method can be used by one thread to cancel a statement that is being executed by another thread. |
protected void |
cancelRequest()
|
protected void |
checkStatement()
This utility method checks if the jdbc statement is closed and throws an exception if it is closed. |
void |
clearBatch()
Makes the set of commands in the current batch empty. |
void |
clearStylesheet()
This method removes any existing style sheet on this object. |
void |
clearWarnings()
Warning could be schema validation errors or partial results warnings. |
void |
close()
In many cases, it is desirable to immediately release a Statements's database and JDBC resources instead of waiting for this to happen when it is automatically closed; the close method provides this immediate release. |
protected void |
copyPropertiesToRequest(RequestMessage res,
java.util.Properties props)
Helper method for copy the connection properties to request message. |
protected RequestMessage |
createRequestMessage(java.lang.String[] commands,
boolean isBatchedCommand,
java.lang.Boolean requiresResultSet)
|
protected void |
createResultSet(ResultsMessage resultsMsg)
|
boolean |
execute(java.lang.String sql)
|
boolean |
execute(java.lang.String sql,
int autoGeneratedKeys)
|
boolean |
execute(java.lang.String sql,
int[] columnIndexes)
|
boolean |
execute(java.lang.String sql,
java.lang.String[] columnNames)
|
int[] |
executeBatch()
|
java.sql.ResultSet |
executeQuery(java.lang.String sql)
|
protected void |
executeSql(java.lang.String[] commands,
boolean isBatchedCommand,
java.lang.Boolean requiresResultSet)
|
int |
executeUpdate(java.lang.String sql)
|
int |
executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
|
int |
executeUpdate(java.lang.String sql,
int[] columnIndexes)
|
int |
executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
|
java.util.Collection |
getAnnotations()
Get annotations |
java.sql.Connection |
getConnection()
|
protected java.util.Properties |
getConnectionProperties()
|
java.lang.String |
getDebugLog()
Get query planner debug log. |
protected ClientSideDQP |
getDQP()
|
java.lang.String |
getExecutionProperty(java.lang.String name)
Get the MetaMatrix-specific execution property value. |
int |
getFetchDirection()
Retreives the fetch direction this Statement object set as a performance hint to the driver. |
int |
getFetchSize()
Retreives the fetch size this Statement object set as a performance hint to the driver. |
java.sql.ResultSet |
getGeneratedKeys()
|
int |
getMaxFieldSize()
Retreives the maximum number of bytes that a result set column may contain. |
int |
getMaxRows()
Retrives the maximum number of rows that a ResultSet object may contain. |
protected MMConnection |
getMMConnection()
|
boolean |
getMoreResults()
Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method #getResultSet. |
boolean |
getMoreResults(int current)
Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object. |
PlanNode |
getPlanDescription()
Get Query plan description. |
int |
getQueryTimeout()
Return the number of seconds the driver will wait for a statement object to execute |
java.lang.String |
getRequestIdentifier()
Get ID for last execution which can be used for matching up executions on the client side with executions in the server logs and MetaMatrix console. |
java.sql.ResultSet |
getResultSet()
Returns a ResultSet object that was produced by a call to the method execute. |
int |
getResultSetConcurrency()
Retrieves the concurrency mode for the ResultSet objects generated from queries that this Statement object executes. |
int |
getResultSetHoldability()
|
int |
getResultSetType()
Retrieves the type of the ResultSet objects generated from queries that this statement executes. |
protected java.util.TimeZone |
getServerTimeZone()
|
int |
getUpdateCount()
This method returns the number of rows affected by a statement modifying a table. |
java.sql.SQLWarning |
getWarnings()
This method returns warnings returned by server. |
protected boolean |
hasResultSet()
|
boolean |
isClosed()
Check is the statement is closed. |
boolean |
isPoolable()
|
protected void |
resetExecutionState()
Reset all per-execution state - this should be done before executing a new command. |
protected ResultsMessage |
sendRequestMessageAndWait(RequestMessage reqMsg)
Send out request message with necessary states. |
protected void |
setAnalysisInfo(ResultsMessage resultsMsg)
|
void |
setCursorName(java.lang.String name)
|
void |
setEscapeProcessing(boolean enable)
This method enbles/disables escape processing. |
void |
setExecutionProperty(java.lang.String name,
java.lang.String value)
Set the MetaMatrix-specific execution property value. |
void |
setFetchDirection(int direction)
This sets the fetch direction that this Statement object's hint to MetaMatrix to improve performance. |
void |
setFetchSize(int rows)
This sets the fetch size that this Statement object's hint to MetaMatrix for improving performance. |
void |
setMaxFieldSize(int max)
|
void |
setMaxRows(int maxRows)
Sets the limit on the maximum number of rows in a ResultSet object. |
void |
setPartialResults(boolean isPartialResults)
|
void |
setPayload(java.io.Serializable payload)
Set the per-statement security payload. |
void |
setPoolable(boolean arg0)
|
void |
setQueryTimeout(int seconds)
This sets to seconds the time limit for the number of seconds for a driver to wait for a statement object to be executed. |
protected void |
timeoutOccurred()
Ends the command and sets the status to TIMED_OUT. |
Methods inherited from class com.metamatrix.jdbc.WrapperImpl |
---|
isWrapperFor, unwrap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.sql.Wrapper |
---|
isWrapperFor, unwrap |
Field Detail |
---|
protected static final int TIMED_OUT
protected static final int CANCELLED
protected static final int NO_TIMEOUT
protected int commandStatus
protected int queryTimeout
protected long currentRequestID
protected MMResultSet resultSet
protected int[] updateCounts
protected java.util.Map outParamIndexMap
Method Detail |
---|
protected ClientSideDQP getDQP()
protected MMConnection getMMConnection()
protected java.util.TimeZone getServerTimeZone() throws java.sql.SQLException
java.sql.SQLException
protected void resetExecutionState() throws java.sql.SQLException
java.sql.SQLException
public void addBatch(java.lang.String sql) throws java.sql.SQLException
addBatch
in interface java.sql.Statement
sql
- statement to be added to the batch
java.sql.SQLException
public void cancel() throws java.sql.SQLException
cancel
in interface java.sql.Statement
java.sql.SQLException
- should never occur.public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Statement
java.sql.SQLException
- should never occur.public void clearBatch() throws java.sql.SQLException
clearBatch
in interface java.sql.Statement
java.sql.SQLException
- if a database access error occurs or the
driver does not support batch statementspublic void close() throws java.sql.SQLException
close
in interface java.sql.Statement
java.sql.SQLException
- should never occur.protected void checkStatement() throws java.sql.SQLException
This utility method checks if the jdbc statement is closed and throws an exception if it is closed.
java.sql.SQLException
- if the statement object is closed.public boolean execute(java.lang.String sql) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public int[] executeBatch() throws java.sql.SQLException
executeBatch
in interface java.sql.Statement
java.sql.SQLException
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
executeQuery
in interface java.sql.Statement
java.sql.SQLException
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
protected boolean hasResultSet() throws java.sql.SQLException
java.sql.SQLException
protected void createResultSet(ResultsMessage resultsMsg) throws java.sql.SQLException
java.sql.SQLException
protected void executeSql(java.lang.String[] commands, boolean isBatchedCommand, java.lang.Boolean requiresResultSet) throws java.sql.SQLException, MMSQLException
java.sql.SQLException
MMSQLException
protected RequestMessage createRequestMessage(java.lang.String[] commands, boolean isBatchedCommand, java.lang.Boolean requiresResultSet)
public int getFetchDirection() throws java.sql.SQLException
getFetchDirection
in interface java.sql.Statement
java.sql.SQLException
- should never occur.public int getFetchSize() throws java.sql.SQLException
getFetchSize
in interface java.sql.Statement
java.sql.SQLException
- should never occur.public int getMaxFieldSize() throws java.sql.SQLException
getMaxFieldSize
in interface java.sql.Statement
java.sql.SQLException
- should never occur.public int getMaxRows() throws java.sql.SQLException
getMaxRows
in interface java.sql.Statement
java.sql.SQLException
- should never iccure.public boolean getMoreResults() throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
java.sql.SQLException
- if there is an error in database.public boolean getMoreResults(int current) throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
current
- flag that gives instruction on what should happen
to current ResultSet objects obtained using the method getResultSet(
CLOSE_CURRENT_RESULT, KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTS).
java.sql.SQLException
- if there is an error in database.public int getQueryTimeout() throws java.sql.SQLException
getQueryTimeout
in interface java.sql.Statement
java.sql.SQLException
- should never occurpublic java.sql.ResultSet getResultSet() throws java.sql.SQLException
getResultSet
in interface java.sql.Statement
java.sql.SQLException
- should never occurpublic int getResultSetConcurrency() throws java.sql.SQLException
getResultSetConcurrency
in interface java.sql.Statement
java.sql.SQLException
- should never occurpublic int getResultSetType()
getResultSetType
in interface java.sql.Statement
java.sql.SQLException
- should never occurpublic int getUpdateCount() throws java.sql.SQLException
getUpdateCount
in interface java.sql.Statement
java.sql.SQLException
- should never occurprotected void accumulateWarnings(java.util.List<java.lang.Exception> serverWarnings)
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Statement
java.sql.SQLException
- should never occurpublic void setEscapeProcessing(boolean enable) throws java.sql.SQLException
setEscapeProcessing
in interface java.sql.Statement
enable
- boolean value indicating if the escape processing should be turned on
java.sql.SQLException
- should never occurpublic void setFetchDirection(int direction) throws java.sql.SQLException
setFetchDirection
in interface java.sql.Statement
direction
- value indicating the direction in which results need to be fetched.
java.sql.SQLException
- as this method is not currently supportedpublic void setFetchSize(int rows) throws java.sql.SQLException
setFetchSize
in interface java.sql.Statement
rows
- Number of rows to fetch at a time
java.sql.SQLException
- If an invalid fetch size is set.public void setMaxRows(int maxRows) throws java.sql.SQLException
setMaxRows
in interface java.sql.Statement
maxRows
- int value indicating maximum rows that can be returned in a ResultSet
java.sql.SQLException
public void setQueryTimeout(int seconds) throws java.sql.SQLException
setQueryTimeout
in interface java.sql.Statement
seconds
- Maximum number of seconds for a statement object to execute.
throws SQLException, should never occur
java.sql.SQLException
protected java.util.Properties getConnectionProperties()
protected void copyPropertiesToRequest(RequestMessage res, java.util.Properties props) throws MMSQLException
res
- Request message that these properties to be copied to.props
- Connection properties.
MMSQLException
protected void timeoutOccurred()
protected void cancelRequest() throws java.sql.SQLException
java.sql.SQLException
public void setPayload(java.io.Serializable payload)
null
, a new payload is set on
the statement or the statement is closed.
To remove an existing payload from a statement, call this method
with a null
argument.
payload
- The payload that is to accompany requests executed
from this statement.public void setExecutionProperty(java.lang.String name, java.lang.String value)
Statement
name
- Execution property namevalue
- Execution property valuepublic java.lang.String getExecutionProperty(java.lang.String name)
Statement
name
- Execution property name
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg) throws java.sql.SQLException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
transaction
- UsertTransactionsql
- String of command or prepared stringlistener
- Message Listenertimeout
- Maybe 0isPreparedStatement
- flag indicating whether this statement is a PreparedStatementisCallableStatement
- flag indicating whether this statement is a CallableStatementparams
- Parameters values of either PreparedStatement or CallableStatementisBatchedCommand
- flag indicating whether the statements are being executed as a batch
java.sql.SQLException
java.util.concurrent.TimeoutException
java.lang.InterruptedException
CommunicationException
public void attachStylesheet(java.io.Reader reader) throws java.io.IOException
This method sets a style sheet to this object. The style sheet is to perform transformations.
reader
- The reader object from which the styleSheet is to be read
java.io.IOException
- if unable to read the style sheet from the Reader object.public void clearStylesheet()
This method removes any existing style sheet on this object.
public PlanNode getPlanDescription()
public java.lang.String getDebugLog()
public java.util.Collection getAnnotations()
public void setPartialResults(boolean isPartialResults)
public java.lang.String getRequestIdentifier()
Statement
public boolean isClosed()
isClosed
in interface java.sql.Statement
protected void setAnalysisInfo(ResultsMessage resultsMsg)
public boolean isPoolable() throws java.sql.SQLException
isPoolable
in interface java.sql.Statement
java.sql.SQLException
public void setPoolable(boolean arg0) throws java.sql.SQLException
setPoolable
in interface java.sql.Statement
java.sql.SQLException
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface java.sql.Statement
java.sql.SQLException
public boolean execute(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public boolean execute(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException
getGeneratedKeys
in interface java.sql.Statement
java.sql.SQLException
public int getResultSetHoldability() throws java.sql.SQLException
getResultSetHoldability
in interface java.sql.Statement
java.sql.SQLException
public void setCursorName(java.lang.String name) throws java.sql.SQLException
setCursorName
in interface java.sql.Statement
java.sql.SQLException
public void setMaxFieldSize(int max) throws java.sql.SQLException
setMaxFieldSize
in interface java.sql.Statement
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |