Top Fields Constructors Methods
com.mysql.cj

public Class ServerPreparedQuery

extends ClientPreparedQuery
Class Inheritance
Known Direct Subclasses
com.mysql.cj.ServerPreparedQueryTestcaseGenerator
Imports
java.io.Closeable, .IOException, .InputStream, .Reader, java.sql.Clob, com.mysql.cj.conf.PropertyKey, .RuntimeProperty, com.mysql.cj.exceptions.CJException, .ExceptionFactory, .MysqlErrorNumbers, .WrongArgumentException, com.mysql.cj.log.ProfilerEvent, com.mysql.cj.protocol.ColumnDefinition, .Message, .ProtocolEntityFactory, .Resultset, .Resultset.Type, com.mysql.cj.protocol.a.ColumnDefinitionFactory, .NativeConstants.IntegerDataType, .NativeConstants.StringLengthDataType, .NativeConstants.StringSelfDataType, .NativeMessageBuilder, .NativePacketPayload, com.mysql.cj.result.Field, com.mysql.cj.telemetry.TelemetryAttribute, .TelemetryScope, .TelemetrySpan, .TelemetrySpanName, com.mysql.cj.util.StringUtils

Field Summary

Modifier and TypeField and Description
public static final int
protected NativeMessageBuilder
protected RuntimeProperty<Boolean>
protected boolean
gatherPerfMetrics

The "gatherPerfMetrics" connection property value

protected boolean
logSlowQueries

The "logSlowQueries" connection property value

public static final byte
public static final byte
private Field[]
parameterFields

Field-level metadata for parameters

protected boolean
profileSQL

The "profileSQL" connection property value

protected boolean
private ColumnDefinition
resultFields

Field-level metadata for result sets.

private long
serverStatementId

The ID that the server uses to identify this PreparedStatement

protected RuntimeProperty<Integer>
private boolean
protected boolean
Inherited from com.mysql.cj.ClientPreparedQuery:
autoClosePStmtStreamsbatchCommandIndexoriginalSqlparameterCountqueryBindingsqueryInfouseStreamLengthsInPrepStmts

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
clearParameters(boolean
flag indicating whether we need an additional clean up
clearServerParameters
)

public void
protected long[]
computeMaxParameterSetSizeAndBatchSize(int
number of batched arguments
numBatchedArgs
)

Overrides com.mysql.cj.ClientPreparedQuery.computeMaxParameterSetSizeAndBatchSize.

Computes the maximum parameter set size and the size of the entire batch given the number of arguments in the batch.

public <M extends Message> M
public static ServerPreparedQuery
public Field[]
public ColumnDefinition
public long
public NativePacketPayload
public <T extends Resultset> T
readExecuteResult(NativePacketPayload resultPacket, int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory, String queryAsString)

public NativePacketPayload
public <
extends Resultset
T extends Resultset
>
T

Returns:

T instance
serverExecute
(int
rows limit
maxRowsToRetrieve
,
boolean
should c/J create a streaming result?
createStreamingResultSet
,
ColumnDefinition
use this metadata instead of the one provided on wire
metadata
,
ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory)

private void
serverLongData(int
parameter index
parameterIndex
,
BindValue binding)

Sends stream-type data parameters to the server.

public void
serverPrepare(String
query string
sql
)

public void
public void
setParameterFields(Field[] parameterFields)

public void
public void
setServerStatementId(long serverStatementId)

public void
private void
storeStreamOrReader(int parameterIndex, NativePacketPayload packet, Closeable streamOrReader)

private String
Inherited from com.mysql.cj.ClientPreparedQuery:
asSqlcheckNullOrEmptyQuerycomputeBatchSizegetBatchCommandIndexgetOriginalSqlgetParameterCountgetQueryBindingsgetQueryInfosetBatchCommandIndexsetOriginalSqlsetParameterCountsetQueryBindingssetQueryInfo

Field Detail

BLOB_STREAM_READ_BUF_SIZEback to summary
public static final int BLOB_STREAM_READ_BUF_SIZE
commandBuilderback to summary
protected NativeMessageBuilder commandBuilder
explainSlowQueriesback to summary
protected RuntimeProperty<Boolean> explainSlowQueries
gatherPerfMetricsback to summary
protected boolean gatherPerfMetrics

The "gatherPerfMetrics" connection property value

logSlowQueriesback to summary
protected boolean logSlowQueries

The "logSlowQueries" connection property value

OPEN_CURSOR_FLAGback to summary
public static final byte OPEN_CURSOR_FLAG
PARAMETER_COUNT_AVAILABLEback to summary
public static final byte PARAMETER_COUNT_AVAILABLE
parameterFieldsback to summary
private Field[] parameterFields

Field-level metadata for parameters

profileSQLback to summary
protected boolean profileSQL

The "profileSQL" connection property value

queryWasSlowback to summary
protected boolean queryWasSlow
resultFieldsback to summary
private ColumnDefinition resultFields

Field-level metadata for result sets. From statement prepare.

serverStatementIdback to summary
private long serverStatementId

The ID that the server uses to identify this PreparedStatement

slowQueryThresholdMillisback to summary
protected RuntimeProperty<Integer> slowQueryThresholdMillis
useAutoSlowLogback to summary
private boolean useAutoSlowLog
useCursorFetchback to summary
protected boolean useCursorFetch

Constructor Detail

ServerPreparedQueryback to summary
protected ServerPreparedQuery(NativeSession sess)

Method Detail

clearParametersback to summary
public void clearParameters(boolean clearServerParameters)
Parameters
clearServerParameters:boolean

flag indicating whether we need an additional clean up

closeQueryback to summary
public void closeQuery()

Overrides com.mysql.cj.ClientPreparedQuery.closeQuery.

Implements com.mysql.cj.Query.closeQuery.

Annotations
@Override
computeMaxParameterSetSizeAndBatchSizeback to summary
protected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)

Overrides com.mysql.cj.ClientPreparedQuery.computeMaxParameterSetSizeAndBatchSize.

Computes the maximum parameter set size and the size of the entire batch given the number of arguments in the batch.

Parameters
numBatchedArgs:int

Doc from com.mysql.cj.ClientPreparedQuery.computeMaxParameterSetSizeAndBatchSize.

number of batched arguments

Returns:long[]

Doc from com.mysql.cj.ClientPreparedQuery.computeMaxParameterSetSizeAndBatchSize.

new long[] { maxSizeOfParameterSet, sizeOfEntireBatch }

Annotations
@Override
fillSendPacketback to summary
public <M extends Message> M fillSendPacket(QueryBindings bindings)

Overrides com.mysql.cj.ClientPreparedQuery.fillSendPacket.

Implements com.mysql.cj.PreparedQuery.fillSendPacket.

Annotations
@Override
getInstanceback to summary
public static ServerPreparedQuery getInstance(NativeSession sess)
getParameterFieldsback to summary
public Field[] getParameterFields()
getResultFieldsback to summary
public ColumnDefinition getResultFields()
getServerStatementIdback to summary
public long getServerStatementId()
prepareExecutePacketback to summary
public NativePacketPayload prepareExecutePacket()
readExecuteResultback to summary
public <T extends Resultset> T readExecuteResult(NativePacketPayload resultPacket, int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory, String queryAsString)
sendExecutePacketback to summary
public NativePacketPayload sendExecutePacket(NativePacketPayload packet, String queryAsString)
serverExecuteback to summary
public <T extends Resultset> T serverExecute(int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory)
Parameters
<T>
extends Resultset
maxRowsToRetrieve:int

rows limit

createStreamingResultSet:boolean

should c/J create a streaming result?

metadata:ColumnDefinition

use this metadata instead of the one provided on wire

resultSetFactory:ProtocolEntityFactory<T, NativePacketPayload>

ProtocolEntityFactory

Returns:T

T instance

serverLongDataback to summary
private void serverLongData(int parameterIndex, BindValue binding)

Sends stream-type data parameters to the server.

 Long data handling:

 - Server gets the long data in pieces with command type 'COM_LONG_DATA'.
 - The packet received will have the format:
   [COM_LONG_DATA:     1][STMT_ID:4][parameter_number:2][type:2][data]
 - Checks if the type is specified by client, and if yes reads the type,
   and  stores the data in that format.
 - It is up to the client to check for read data ended. The server does not
   care; and also server does not notify to the client that it got the
   data  or not; if there is any error; then during execute; the error
   will  be returned
Parameters
parameterIndex:int

parameter index

binding:BindValue

containing long data

serverPrepareback to summary
public void serverPrepare(String sql) throws IOException
Parameters
sql:String

query string

Exceptions
IOException:
if an i/o error occurs
serverResetStatementback to summary
public void serverResetStatement()
setParameterFieldsback to summary
public void setParameterFields(Field[] parameterFields)
setResultFieldsback to summary
public void setResultFields(ColumnDefinition resultFields)
setServerStatementIdback to summary
public void setServerStatementId(long serverStatementId)
statementBeginsback to summary
public void statementBegins()

Overrides com.mysql.cj.AbstractQuery.statementBegins.

Implements com.mysql.cj.Query.statementBegins.

Annotations
@Override
storeStreamOrReaderback to summary
private void storeStreamOrReader(int parameterIndex, NativePacketPayload packet, Closeable streamOrReader)
truncateQueryToLogback to summary
private String truncateQueryToLog(String sql)