public class ServerPreparedStatement extends ClientPreparedStatement
Query.CancelStatus
Modifier and Type | Field and Description |
---|---|
protected boolean |
isCacheable |
protected boolean |
isCached |
batchedValuesClause, batchHasPlainStatements, parameterMetaData, rewrittenBatchSize
batchedGeneratedKeys, charEncoding, commandBuilder, connection, continueBatchOnError, doEscapeProcessing, dontCheckOnDuplicateKeyUpdateInSQL, dontTrackOpenResources, dumpQueriesOnException, exceptionInterceptor, generatedKeysResults, holdResultsOpenOverClose, isClosed, lastInsertId, lastQueryIsOnDupKeyUpdate, logSlowQueries, maxAllowedPacket, maxFieldSize, maxRows, openResults, pedantic, PING_MARKER, pingTarget, profileSQL, query, results, resultSetConcurrency, resultSetFactory, retrieveGeneratedKeys, rewriteBatchedStatements, session, updateCount, USES_VARIABLES_FALSE, USES_VARIABLES_TRUE, USES_VARIABLES_UNKNOWN, useUsageAdvisor, warningChain
MAX_ROWS
Modifier | Constructor and Description |
---|---|
protected |
ServerPreparedStatement(JdbcConnection conn,
java.lang.String sql,
java.lang.String db,
int resultSetType,
int resultSetConcurrency)
Creates a new ServerPreparedStatement object.
|
Modifier and Type | Method and Description |
---|---|
void |
addBatch() |
protected void |
checkBounds(int parameterIndex,
int parameterIndexOffset) |
protected JdbcConnection |
checkClosed()
Checks if closed() has been called, and throws an exception if so
|
void |
clearParameters() |
void |
close()
In many cases, it is desirable to immediately release a Statement's
database and JDBC resources instead of waiting for this to happen when it
is automatically closed.
|
protected boolean |
containsOnDuplicateKeyUpdate() |
protected long[] |
executeBatchSerially(int batchTimeout)
Executes the current batch of statements by executing them one-by-one.
|
protected <M extends Message> |
executeInternal(int maxRowsToRetrieve,
M sendPacket,
boolean createStreamingResultSet,
boolean queryIsSelectOnly,
ColumnDefinition metadata,
boolean isBatch)
Actually execute the prepared statement.
|
protected BindValue |
getBinding(int parameterIndex,
boolean forLongData)
Returns the structure representing the value that (can be)/(is)
bound at the given parameter index.
|
protected static ServerPreparedStatement |
getInstance(JdbcConnection conn,
java.lang.String sql,
java.lang.String db,
int resultSetType,
int resultSetConcurrency)
Creates a prepared statement instance
|
java.sql.ResultSetMetaData |
getMetaData() |
java.sql.ParameterMetaData |
getParameterMetaData() |
long |
getServerStatementId() |
protected void |
initQuery() |
boolean |
isNull(int paramIndex) |
protected ClientPreparedStatement |
prepareBatchedInsertSQL(JdbcConnection localConn,
int numBatches)
Returns a prepared statement for the number of batched parameters, used when re-writing batch INSERTs.
|
void |
realClose(boolean calledExplicitly,
boolean closeOpenResults)
Closes this statement, and frees resources.
|
protected void |
rePrepare()
Used by Connection when auto-reconnecting to retrieve 'lost' prepared
statements.
|
protected ResultSetInternalMethods |
serverExecute(int maxRowsToRetrieve,
boolean createStreamingResultSet,
ColumnDefinition metadata)
Tells the server to execute this prepared statement with the current
parameter bindings.
|
protected void |
serverPrepare(java.lang.String sql) |
protected void |
setClosed(boolean flag) |
void |
setPoolable(boolean poolable) |
void |
setUnicodeStream(int parameterIndex,
java.io.InputStream x,
int length)
Deprecated.
|
void |
setURL(int parameterIndex,
java.net.URL x) |
java.lang.String |
toString()
Returns this PreparedStatement represented as a string.
|
addBatch, checkReadOnlySafeStatement, clearBatch, execute, executeBatchInternal, executeBatchWithMultiValuesClause, executeLargeUpdate, executePreparedBatchAsMultiStatement, executeQuery, executeUpdate, executeUpdateInternal, executeUpdateInternal, getBytesRepresentation, getCoreParameterIndex, getInstance, getInstance, getParameterBindings, getParameterIndexOffset, getPreparedSql, getQueryBindings, getQueryInfo, getUpdateCount, isResultSetProducingQuery, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBigInteger, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBoolean, setByte, setBytes, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setDate, setDate, setDouble, setFloat, setInt, setLong, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setNull, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setOneBatchedParameterSet, setRef, setRetrieveGeneratedKeys, setRowId, setShort, setSQLXML, setString, setTime, setTime, setTimestamp, setTimestamp
addBatch, cancel, checkCancelTimeout, checkNullOrEmptyQuery, clearAttributes, clearBatchedArgs, clearWarnings, closeAllOpenResults, closeOnCompletion, closeQuery, containsOnDuplicateKeyInString, createStreamingResultSet, disableStreamingResults, doPingInstead, enableStreamingResults, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeSimpleNonQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdateInternal, generatePingResultSet, getBatchedArgs, getBatchedGeneratedKeys, getBatchedGeneratedKeys, getCancelTimeoutMutex, getConnection, getCurrentDatabase, getExceptionInterceptor, getExecuteTime, getFetchDirection, getFetchSize, getGeneratedKeys, getGeneratedKeysInternal, getGeneratedKeysInternal, getId, getLargeMaxRows, getLargeUpdateCount, getLastInsertID, getLocalInfileInputStream, getLongUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getOpenResultSetCount, getQuery, getQueryAttributesBindings, getQueryTimeout, getResultFetchSize, getResultSet, getResultSetConcurrency, getResultSetFactory, getResultSetHoldability, getResultSetInternal, getResultSetType, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, getWarnings, handleExceptionForBatch, hasDeadlockOrTimeoutRolledBackTx, implicitlyCloseAllOpenResults, isClearWarningsCalled, isClosed, isCloseOnCompletion, isNonResultSetProducingQuery, isPoolable, isResultSetProducingQuery, isWrapperFor, processMultiCountsAndKeys, removeOpenResultSet, resetCancelledState, setAttribute, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setCursorName, setEscapeProcessing, setExecuteTime, setFetchDirection, setFetchSize, setHoldResultsOpenOverClose, setLargeMaxRows, setLocalInfileInputStream, setMaxFieldSize, setMaxRows, setPingTarget, setQueryTimeout, setResultFetchSize, setResultType, setTimeoutInMillis, setupStreamingTimeout, startQueryTimer, statementBegins, stopQueryTimer, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clearAttributes, disableStreamingResults, enableStreamingResults, getExceptionInterceptor, getLocalInfileInputStream, getOpenResultSetCount, getQuery, getResultSetInternal, removeOpenResultSet, setAttribute, setHoldResultsOpenOverClose, setLocalInfileInputStream, setPingTarget
cancel, clearWarnings, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, isClosed, isCloseOnCompletion, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setQueryTimeout
addBatch, checkCancelTimeout, clearBatchedArgs, closeQuery, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getQueryAttributesBindings, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, statementBegins, stopQueryTimer
protected ServerPreparedStatement(JdbcConnection conn, java.lang.String sql, java.lang.String db, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
conn
- the connection creating us.sql
- the SQL containing the statement to prepare.db
- the database in use when we were created.resultSetType
- ResultSet typeresultSetConcurrency
- ResultSet concurrencyjava.sql.SQLException
- If an error occursprotected static ServerPreparedStatement getInstance(JdbcConnection conn, java.lang.String sql, java.lang.String db, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
conn
- the connection creating us.sql
- the SQL containing the statement to prepare.db
- the database in use when we were created.resultSetType
- ResultSet typeresultSetConcurrency
- ResultSet concurrencyjava.sql.SQLException
- If an error occursprotected void initQuery()
initQuery
in class ClientPreparedStatement
public java.lang.String toString()
ClientPreparedStatement
toString
in class ClientPreparedStatement
public void addBatch() throws java.sql.SQLException
addBatch
in interface java.sql.PreparedStatement
addBatch
in class ClientPreparedStatement
java.sql.SQLException
protected JdbcConnection checkClosed()
StatementImpl
checkClosed
in class StatementImpl
public void clearParameters()
clearParameters
in interface java.sql.PreparedStatement
clearParameters
in class ClientPreparedStatement
protected void setClosed(boolean flag)
public void close() throws java.sql.SQLException
StatementImpl
Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed, its current ResultSet, if one exists, is also closed.
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Statement
close
in class StatementImpl
java.sql.SQLException
- if a database access error occursprotected long[] executeBatchSerially(int batchTimeout) throws java.sql.SQLException
ClientPreparedStatement
executeBatchSerially
in class ClientPreparedStatement
batchTimeout
- timeout for the batch executionjava.sql.SQLException
- if an error occursprotected <M extends Message> ResultSetInternalMethods executeInternal(int maxRowsToRetrieve, M sendPacket, boolean createStreamingResultSet, boolean queryIsSelectOnly, ColumnDefinition metadata, boolean isBatch) throws java.sql.SQLException
ClientPreparedStatement
executeInternal
in class ClientPreparedStatement
M
- extends Message
maxRowsToRetrieve
- the max number of rows to returnsendPacket
- the packet to sendcreateStreamingResultSet
- should a 'streaming' result set be created?queryIsSelectOnly
- is this query doing a SELECT?metadata
- use this metadata instead of the one provided on wireisBatch
- is this a batch query?java.sql.SQLException
- if an error occurs.protected BindValue getBinding(int parameterIndex, boolean forLongData) throws java.sql.SQLException
parameterIndex
- 1-basedforLongData
- is this for a stream?BindValue
java.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatementpublic java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.PreparedStatement
getMetaData
in class ClientPreparedStatement
java.sql.SQLException
public java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLException
getParameterMetaData
in interface java.sql.PreparedStatement
getParameterMetaData
in class ClientPreparedStatement
java.sql.SQLException
public boolean isNull(int paramIndex)
isNull
in interface JdbcPreparedStatement
isNull
in class ClientPreparedStatement
public void realClose(boolean calledExplicitly, boolean closeOpenResults) throws java.sql.SQLException
StatementImpl
realClose
in interface JdbcPreparedStatement
realClose
in class ClientPreparedStatement
calledExplicitly
- was this called from close()?closeOpenResults
- should open result sets be closed?java.sql.SQLException
- if an error occursprotected void rePrepare()
CJException
- if an error occurs.protected ResultSetInternalMethods serverExecute(int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata) throws java.sql.SQLException
- Server gets the command 'COM_EXECUTE' to execute the previously prepared query. If there is any param markers; then client will send the data in the following format: [COM_EXECUTE:1] [STMT_ID:4] [NULL_BITS:(param_count+7)/8)] [TYPES_SUPPLIED_BY_CLIENT(0/1):1] [[length]data] [[length]data] .. [[length]data]. (Note: Except for string/binary types; all other types will not be supplied with length field)
maxRowsToRetrieve
- rows limitcreateStreamingResultSet
- should c/J create a streaming result?metadata
- use this metadata instead of the one provided on wirejava.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatementprotected void serverPrepare(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
protected void checkBounds(int parameterIndex, int parameterIndexOffset) throws java.sql.SQLException
checkBounds
in class ClientPreparedStatement
java.sql.SQLException
@Deprecated public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException
setUnicodeStream
in interface java.sql.PreparedStatement
setUnicodeStream
in class ClientPreparedStatement
java.sql.SQLException
public void setURL(int parameterIndex, java.net.URL x) throws java.sql.SQLException
setURL
in interface java.sql.PreparedStatement
setURL
in class ClientPreparedStatement
java.sql.SQLException
public long getServerStatementId()
getServerStatementId
in class StatementImpl
protected boolean containsOnDuplicateKeyUpdate()
containsOnDuplicateKeyUpdate
in class ClientPreparedStatement
protected ClientPreparedStatement prepareBatchedInsertSQL(JdbcConnection localConn, int numBatches) throws java.sql.SQLException
ClientPreparedStatement
prepareBatchedInsertSQL
in class ClientPreparedStatement
localConn
- the connection creating this statementnumBatches
- number of entries in a batchjava.sql.SQLException
- if a database access error occurs or this method is called on a closed PreparedStatementpublic void setPoolable(boolean poolable) throws java.sql.SQLException
setPoolable
in interface java.sql.Statement
setPoolable
in class StatementImpl
java.sql.SQLException