Package com.mysql.cj
Class AbstractPreparedQuery<T extends QueryBindings<?>>
java.lang.Object
com.mysql.cj.AbstractQuery
com.mysql.cj.AbstractPreparedQuery<T>
- All Implemented Interfaces:
PreparedQuery<T>
,Query
- Direct Known Subclasses:
ClientPreparedQuery
,ServerPreparedQuery
public abstract class AbstractPreparedQuery<T extends QueryBindings<?>> extends AbstractQuery implements PreparedQuery<T>
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected RuntimeProperty<java.lang.Boolean>
autoClosePStmtStreams
protected int
batchCommandIndex
Command index of currently executing batch command.protected java.lang.String
originalSql
The SQL that was passed in to 'prepare'protected int
parameterCount
The number of parameters in this PreparedStatementprotected ParseInfo
parseInfo
protected T
queryBindings
protected RuntimeProperty<java.lang.Boolean>
useStreamLengthsInPrepStmts
Fields inherited from class com.mysql.cj.AbstractQuery
batchedArgs, cancelTimeoutMutex, charEncoding, clearWarningsCalled, currentDb, fetchSize, maxAllowedPacket, resultSetType, session, statementExecuting, statementId, timeoutInMillis
-
Constructor Summary
Constructors Constructor Description AbstractPreparedQuery(NativeSession sess)
-
Method Summary
Modifier and Type Method Description java.lang.String
asSql()
java.lang.String
asSql(boolean quoteStreamsAndUnknowns)
void
checkNullOrEmptyQuery(java.lang.String sql)
Method checkNullOrEmptyQuery.void
closeQuery()
int
computeBatchSize(int numBatchedArgs)
Computes the optimum number of batched parameter lists to send without overflowing max_allowed_packet.protected abstract long[]
computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)
<M extends Message>
MfillSendPacket()
Creates the packet that contains the query to be sent to the server.<M extends Message>
MfillSendPacket(QueryBindings<?> bindings)
Creates the packet that contains the query to be sent to the server.int
getBatchCommandIndex()
java.lang.String
getOriginalSql()
int
getParameterCount()
ParseInfo
getParseInfo()
T
getQueryBindings()
void
setBatchCommandIndex(int batchCommandIndex)
void
setOriginalSql(java.lang.String originalSql)
void
setParameterCount(int parameterCount)
void
setParseInfo(ParseInfo parseInfo)
void
setQueryBindings(T queryBindings)
Methods inherited from class com.mysql.cj.AbstractQuery
addBatch, checkCancelTimeout, clearBatchedArgs, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, statementBegins, stopQueryTimer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mysql.cj.Query
addBatch, checkCancelTimeout, clearBatchedArgs, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, statementBegins, stopQueryTimer
-
Field Details
-
parseInfo
-
queryBindings
-
originalSql
protected java.lang.String originalSqlThe SQL that was passed in to 'prepare' -
parameterCount
protected int parameterCountThe number of parameters in this PreparedStatement -
autoClosePStmtStreams
-
batchCommandIndex
protected int batchCommandIndexCommand index of currently executing batch command. -
useStreamLengthsInPrepStmts
-
-
Constructor Details
-
Method Details
-
closeQuery
public void closeQuery()- Specified by:
closeQuery
in interfaceQuery
- Overrides:
closeQuery
in classAbstractQuery
-
getParseInfo
- Specified by:
getParseInfo
in interfacePreparedQuery<T extends QueryBindings<?>>
-
setParseInfo
- Specified by:
setParseInfo
in interfacePreparedQuery<T extends QueryBindings<?>>
-
getOriginalSql
public java.lang.String getOriginalSql()- Specified by:
getOriginalSql
in interfacePreparedQuery<T extends QueryBindings<?>>
-
setOriginalSql
public void setOriginalSql(java.lang.String originalSql)- Specified by:
setOriginalSql
in interfacePreparedQuery<T extends QueryBindings<?>>
-
getParameterCount
public int getParameterCount()- Specified by:
getParameterCount
in interfacePreparedQuery<T extends QueryBindings<?>>
-
setParameterCount
public void setParameterCount(int parameterCount)- Specified by:
setParameterCount
in interfacePreparedQuery<T extends QueryBindings<?>>
-
getQueryBindings
- Specified by:
getQueryBindings
in interfacePreparedQuery<T extends QueryBindings<?>>
-
setQueryBindings
- Specified by:
setQueryBindings
in interfacePreparedQuery<T extends QueryBindings<?>>
-
getBatchCommandIndex
public int getBatchCommandIndex()- Specified by:
getBatchCommandIndex
in interfacePreparedQuery<T extends QueryBindings<?>>
-
setBatchCommandIndex
public void setBatchCommandIndex(int batchCommandIndex)- Specified by:
setBatchCommandIndex
in interfacePreparedQuery<T extends QueryBindings<?>>
-
computeBatchSize
public int computeBatchSize(int numBatchedArgs)Computes the optimum number of batched parameter lists to send without overflowing max_allowed_packet.- Specified by:
computeBatchSize
in interfacePreparedQuery<T extends QueryBindings<?>>
- Parameters:
numBatchedArgs
- original batch size- Returns:
- computed batch size
-
checkNullOrEmptyQuery
public void checkNullOrEmptyQuery(java.lang.String sql)Method checkNullOrEmptyQuery.- Specified by:
checkNullOrEmptyQuery
in interfacePreparedQuery<T extends QueryBindings<?>>
- Parameters:
sql
- the SQL to check- Throws:
WrongArgumentException
- if query is null or empty.
-
asSql
public java.lang.String asSql()- Specified by:
asSql
in interfacePreparedQuery<T extends QueryBindings<?>>
-
asSql
public java.lang.String asSql(boolean quoteStreamsAndUnknowns)- Specified by:
asSql
in interfacePreparedQuery<T extends QueryBindings<?>>
-
computeMaxParameterSetSizeAndBatchSize
protected abstract long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs) -
fillSendPacket
Creates the packet that contains the query to be sent to the server.- Specified by:
fillSendPacket
in interfacePreparedQuery<T extends QueryBindings<?>>
- Returns:
- A Buffer filled with the query representing the PreparedStatement.
-
fillSendPacket
Creates the packet that contains the query to be sent to the server.- Specified by:
fillSendPacket
in interfacePreparedQuery<T extends QueryBindings<?>>
- Parameters:
bindings
- values- Returns:
- a Buffer filled with the query that represents this statement
-