Package com.mysql.cj
Class AbstractQuery
java.lang.Object
com.mysql.cj.AbstractQuery
- All Implemented Interfaces:
Query
- Direct Known Subclasses:
AbstractPreparedQuery
,SimpleQuery
public abstract class AbstractQuery extends java.lang.Object implements Query
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.Object>
batchedArgs
Holds batched commandsprotected java.lang.Object
cancelTimeoutMutex
Mutex to prevent race between returning query results and noticing that query has been timed-out or cancelled.protected java.lang.String
charEncoding
The character encoding to use (if available)protected boolean
clearWarningsCalled
Has clearWarnings() been called?protected java.lang.String
currentDb
The database in useprotected int
fetchSize
The number of rows to fetch at a time (currently ignored)protected RuntimeProperty<java.lang.Integer>
maxAllowedPacket
protected Resultset.Type
resultSetType
The type of this result set (scroll sensitive or in-sensitive)NativeSession
session
protected java.util.concurrent.atomic.AtomicBoolean
statementExecuting
Currently executing a statement?protected int
statementId
Used to identify this statement when profiling.protected int
timeoutInMillis
The timeout for a query -
Constructor Summary
Constructors Constructor Description AbstractQuery(NativeSession sess)
-
Method Summary
Modifier and Type Method Description void
addBatch(java.lang.Object batch)
void
checkCancelTimeout()
void
clearBatchedArgs()
void
closeQuery()
java.util.List<java.lang.Object>
getBatchedArgs()
Get the batched args as added by the addBatch method(s).java.lang.Object
getCancelTimeoutMutex()
java.lang.String
getCurrentDatabase()
long
getExecuteTime()
Returns the elapsed time for the server to execute the query.int
getId()
Returns the query id used when profilingint
getResultFetchSize()
<T extends Resultset, M extends Message>
ProtocolEntityFactory<T,M>getResultSetFactory()
Resultset.Type
getResultType()
NativeSession
getSession()
java.util.concurrent.atomic.AtomicBoolean
getStatementExecuting()
int
getTimeoutInMillis()
boolean
isClearWarningsCalled()
void
resetCancelledState()
void
setCancelStatus(Query.CancelStatus cs)
void
setClearWarningsCalled(boolean clearWarningsCalled)
void
setCurrentDatabase(java.lang.String currentDb)
void
setExecuteTime(long executeTime)
void
setResultFetchSize(int fetchSize)
void
setResultType(Resultset.Type resultSetType)
void
setTimeoutInMillis(int timeoutInMillis)
CancelQueryTask
startQueryTimer(Query stmtToCancel, int timeout)
void
statementBegins()
void
stopQueryTimer(CancelQueryTask timeoutTask, boolean rethrowCancelReason, boolean checkCancelTimeout)
-
Field Details
-
session
-
statementId
protected int statementIdUsed to identify this statement when profiling. -
maxAllowedPacket
-
charEncoding
protected java.lang.String charEncodingThe character encoding to use (if available) -
cancelTimeoutMutex
protected java.lang.Object cancelTimeoutMutexMutex to prevent race between returning query results and noticing that query has been timed-out or cancelled. -
timeoutInMillis
protected int timeoutInMillisThe timeout for a query -
batchedArgs
protected java.util.List<java.lang.Object> batchedArgsHolds batched commands -
resultSetType
The type of this result set (scroll sensitive or in-sensitive) -
fetchSize
protected int fetchSizeThe number of rows to fetch at a time (currently ignored) -
statementExecuting
protected final java.util.concurrent.atomic.AtomicBoolean statementExecutingCurrently executing a statement? -
currentDb
protected java.lang.String currentDbThe database in use -
clearWarningsCalled
protected boolean clearWarningsCalledHas clearWarnings() been called?
-
-
Constructor Details
-
Method Details
-
getId
public int getId()Description copied from interface:Query
Returns the query id used when profiling -
setCancelStatus
- Specified by:
setCancelStatus
in interfaceQuery
-
getExecuteTime
public long getExecuteTime()Description copied from interface:Query
Returns the elapsed time for the server to execute the query.- Specified by:
getExecuteTime
in interfaceQuery
- Returns:
- the time it took for the server to execute the query.
-
setExecuteTime
public void setExecuteTime(long executeTime)- Specified by:
setExecuteTime
in interfaceQuery
-
checkCancelTimeout
public void checkCancelTimeout()- Specified by:
checkCancelTimeout
in interfaceQuery
-
resetCancelledState
public void resetCancelledState()- Specified by:
resetCancelledState
in interfaceQuery
-
getResultSetFactory
- Specified by:
getResultSetFactory
in interfaceQuery
-
getSession
- Specified by:
getSession
in interfaceQuery
-
getCancelTimeoutMutex
public java.lang.Object getCancelTimeoutMutex()- Specified by:
getCancelTimeoutMutex
in interfaceQuery
-
closeQuery
public void closeQuery()- Specified by:
closeQuery
in interfaceQuery
-
addBatch
public void addBatch(java.lang.Object batch) -
getBatchedArgs
public java.util.List<java.lang.Object> getBatchedArgs()Description copied from interface:Query
Get the batched args as added by the addBatch method(s). The list is unmodifiable and might contain any combination of String, ClientPreparedQueryBindings, or ServerPreparedQueryBindings depending on how the parameters were batched.- Specified by:
getBatchedArgs
in interfaceQuery
- Returns:
- an unmodifiable List of batched args
-
clearBatchedArgs
public void clearBatchedArgs()- Specified by:
clearBatchedArgs
in interfaceQuery
-
getResultFetchSize
public int getResultFetchSize()- Specified by:
getResultFetchSize
in interfaceQuery
-
setResultFetchSize
public void setResultFetchSize(int fetchSize)- Specified by:
setResultFetchSize
in interfaceQuery
-
getResultType
- Specified by:
getResultType
in interfaceQuery
-
setResultType
- Specified by:
setResultType
in interfaceQuery
-
getTimeoutInMillis
public int getTimeoutInMillis()- Specified by:
getTimeoutInMillis
in interfaceQuery
-
setTimeoutInMillis
public void setTimeoutInMillis(int timeoutInMillis)- Specified by:
setTimeoutInMillis
in interfaceQuery
-
startQueryTimer
- Specified by:
startQueryTimer
in interfaceQuery
-
stopQueryTimer
public void stopQueryTimer(CancelQueryTask timeoutTask, boolean rethrowCancelReason, boolean checkCancelTimeout)- Specified by:
stopQueryTimer
in interfaceQuery
-
getStatementExecuting
public java.util.concurrent.atomic.AtomicBoolean getStatementExecuting()- Specified by:
getStatementExecuting
in interfaceQuery
-
getCurrentDatabase
public java.lang.String getCurrentDatabase()- Specified by:
getCurrentDatabase
in interfaceQuery
-
setCurrentDatabase
public void setCurrentDatabase(java.lang.String currentDb)- Specified by:
setCurrentDatabase
in interfaceQuery
-
isClearWarningsCalled
public boolean isClearWarningsCalled()- Specified by:
isClearWarningsCalled
in interfaceQuery
-
setClearWarningsCalled
public void setClearWarningsCalled(boolean clearWarningsCalled)- Specified by:
setClearWarningsCalled
in interfaceQuery
-
statementBegins
public void statementBegins()- Specified by:
statementBegins
in interfaceQuery
-