Top Fields Constructors Methods
com.mysql.cj.protocol.a

public Class NativeProtocol

extends AbstractProtocol<NativePacketPayload>
implements RuntimePropertyListener
Class Inheritance
All Implemented Interfaces
com.mysql.cj.conf.RuntimeProperty.RuntimePropertyListener
Imports
java.io.BufferedInputStream, .File, .FileInputStream, .IOException, .InputStream, .Reader, java.lang.management.ManagementFactory, .ThreadInfo, .ThreadMXBean, java.lang.ref.SoftReference, java.math.BigDecimal, .BigInteger, java.net.InetAddress, .MalformedURLException, .Socket, .URISyntaxException, .URL, .UnknownHostException, java.nio.file.InvalidPathException, .Path, .Paths, java.sql.Blob, .Clob, .DataTruncation, .Date, .SQLWarning, .Time, .Timestamp, java.time.Duration, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .OffsetDateTime, .OffsetTime, .ZoneId, .ZoneOffset, .ZonedDateTime, java.util.ArrayList, .Calendar, .Collections, .HashMap, .Iterator, .LinkedList, .List, .Map, .Map.Entry, .Optional, .TimeZone, java.util.function.Supplier, com.mysql.cj.CharsetMapping, .MessageBuilder, .Messages, .MysqlType, .NativeCharsetSettings, .NativeSession, .Query, .QueryResult, .ServerPreparedQuery, .ServerVersion, .Session, .TransactionEventHandler, com.mysql.cj.conf.PropertyKey, .PropertySet, .RuntimeProperty, .RuntimeProperty.RuntimePropertyListener, com.mysql.cj.exceptions.CJCommunicationsException, .CJConnectionFeatureNotAvailableException, .CJException, .CJOperationNotSupportedException, .CJPacketTooBigException, .ClosedOnExpiredPasswordException, .DataTruncationException, .ExceptionFactory, .FeatureNotAvailableException, .MysqlErrorNumbers, .PasswordExpiredException, .WrongArgumentException, com.mysql.cj.interceptors.QueryInterceptor, com.mysql.cj.jdbc.exceptions.MysqlDataTruncation, com.mysql.cj.log.BaseMetricsHolder, .Log, .ProfilerEvent, .ProfilerEventHandler, com.mysql.cj.protocol.AbstractProtocol, .ColumnDefinition, .ExportControlled, .FullReadInputStream, .Message, .MessageReader, .MessageSender, .PacketReceivedTimeHolder, .PacketSentTimeHolder, .ProtocolEntity, .ProtocolEntityFactory, .ProtocolEntityReader, .ResultBuilder, .Resultset, .Resultset.Concurrency, .Resultset.Type, .ResultsetRow, .ResultsetRows, .ServerSession, .SocketConnection, .ValueEncoder, com.mysql.cj.protocol.a.NativeConstants.IntegerDataType, .NativeConstants.StringLengthDataType, .NativeConstants.StringSelfDataType, com.mysql.cj.protocol.a.result.OkPacket, com.mysql.cj.result.Field, .IntegerValueFactory, .Row, .StringValueFactory, .ValueFactory, com.mysql.cj.telemetry.TelemetryAttribute, .TelemetryScope, .TelemetrySpan, .TelemetrySpanName, com.mysql.cj.util.LazyString, .StringUtils, .TestUtils, .TimeUtil, .Util

Field Summary

Modifier and TypeField and Description
private boolean
private int
protected static final int
protected CompressedPacketSender
compressedPacketSender

Track this to manually shut down.

pack-priv static Map<Class<?>, Supplier<ValueEncoder>>
private static final String
private static final String[]
protected boolean
protected static final int
private SoftReference<NativePacketPayload>
loadFileBufRef

Packet used for 'LOAD DATA LOCAL INFILE' We use a SoftReference, so that we don't penalize intermittent use of this feature

private InputStream
private boolean
private RuntimeProperty<Boolean>
protected static final int
private RuntimeProperty<Integer>
private RuntimeProperty<Integer>
private BaseMetricsHolder
private NativeMessageBuilder
protected MessageReader<NativePacketHeader, NativePacketPayload>
protected MessageSender<NativePacketPayload>
protected byte
private boolean
protected Map<Class<? extends ProtocolEntity>, ProtocolEntityReader<? extends ProtocolEntity, ? extends Message>>
protected Map<Class<? extends ProtocolEntity>, ProtocolEntityReader<? extends ProtocolEntity, ? extends Message>>
private List<QueryInterceptor>
protected NativePacketPayload
reusablePacket

Use this when reading in rows to avoid thousands of new() calls, because the byte arrays just get copied out of the packet anyway

protected NativeServerSession
protected NativePacketPayload
private long
protected static final int
private int
private ResultsetRows
private boolean
protected boolean
private RuntimeProperty<Boolean>
private int
Inherited from com.mysql.cj.protocol.AbstractProtocol:
authProviderexceptionInterceptorlogmessageBuilderpacketDebugRingBufferpropertySetqueryTimingUnitssessionsocketConnectiontransactionManageruseNanosForElapsedTime

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private int
alignPacketSize(int a, int l)

private void
private StringBuilder
public void
applyPacketDecorators(MessageSender<NativePacketPayload> sender, MessageReader<NativePacketHeader, NativePacketPayload> messageReader)

Apply optional decorators to configured PacketSender and PacketReader.

public void
private void
public void
public void
changeUser(String
user name
user
,
String
password
password
,
String
database name
database
)

Implements com.mysql.cj.protocol.Protocol.changeUser.

Re-authenticates as the given user and password

public NativePacketPayload
checkErrorMessage()

Implements com.mysql.cj.protocol.Protocol.checkErrorMessage.

Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for reading

private NativePacketPayload

Returns:

NativePacketPayload
checkErrorMessage
(int
the command being issued (if used)
command
)

Checks for errors in the reply packet, and if none, returns the reply packet, ready for reading

public void
private void
public void
public void
public void
public void
configureTimeZone()

Implements com.mysql.cj.protocol.Protocol.configureTimeZone.

Configures the client's timezone if required.

public void
connect(String
DB user name
user
,
String
DB user password
password
,
String
database name
database
)

Implements com.mysql.cj.protocol.Protocol.connect.

Create a new session.

public SQLWarning

Returns:

the SQLWarning chain (or null if no warnings)
convertShowWarningsToSQLWarnings
(boolean
if this method should only scan for data truncation warnings
forTruncationOnly
)

Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.

public void
public void
explainSlowQuery(String
full query string
query
,
String
query string truncated for profiling
truncatedQuery
)

Runs an 'EXPLAIN' on the given query and dumps the results to the log

public static MysqlType
findMysqlType(PropertySet propertySet, int mysqlTypeId, short colFlag, long length, LazyString tableName, LazyString originalTableName, int collationIndex, String encoding)

public StringBuilder
public int
public long
private BufferedInputStream
public static NativeProtocol
getInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log, TransactionEventHandler transactionManager)

public InputStream
getLocalInfileInputStream()

Implements com.mysql.cj.protocol.Protocol.getLocalInfileInputStream.

Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement.

public MessageBuilder<NativePacketPayload>
public BaseMetricsHolder
private NativeMessageBuilder
public MessageReader<NativePacketHeader, NativePacketPayload>
public MessageSender<NativePacketPayload>
public List<QueryInterceptor>
public NativePacketPayload
public NativeServerSession
public Session
public NativePacketPayload

Returns:

A packet to send data with
getSharedSendPacket
()

Returns the packet used for sending data (used by PreparedStatement) with position set to 0.

public long
public ResultsetRows
public Supplier<ValueEncoder>
public int
public boolean
public void
public void
public void
public <T extends Resultset> T
invokeQueryInterceptorsPost(Supplier<String> sql, Query interceptedQuery, T originalResultSet, boolean forceExecute)

public <
extends Message
M extends Message
>
M

Returns:

T instance
invokeQueryInterceptorsPost
(M
NativePacketPayload containing query
queryPacket
,
M
NativePacketPayload containing response
originalResponsePacket
,
boolean
currently ignored
forceExecute
)

public <T extends Resultset> T
invokeQueryInterceptorsPre(Supplier<String> sql, Query interceptedQuery, boolean forceExecute)

public <
extends Message
M extends Message
>
M

Returns:

M instance
invokeQueryInterceptorsPre
(M
NativePacketPayload containing query
queryPacket
,
boolean
currently ignored
forceExecute
)

protected boolean
public void
negotiateSSLConnection()

Implements com.mysql.cj.protocol.Protocol.negotiateSSLConnection.

Negotiates the SSL communication channel used when connecting to a MySQL server that has SSL enabled.

public final NativePacketPayload
public final void
quit()

Log-off of the MySQL server and close the socket.

public <T extends ProtocolEntity> T
read(Class<T> requiredClass, ProtocolEntityFactory<T, NativePacketPayload> protocolEntityFactory)

Implements com.mysql.cj.protocol.Protocol.read.

public <T extends ProtocolEntity> T
read(Class<Resultset>
required Resultset class
requiredClass
,
int
the maximum number of rows to read (-1 means all rows)
maxRows
,
boolean
should the driver leave the results on the wire, and read them only when needed?
streamResults
,
NativePacketPayload
the first packet of information in the result set
resultPacket
,
boolean
true if the binary protocol is used (for server prepared statements)
isBinaryEncoded
,
ColumnDefinition
use this metadata instead of the one provided on wire
metadata
,
ProtocolEntityFactory<T, NativePacketPayload> protocolEntityFactory)

Implements com.mysql.cj.protocol.Protocol.read.

Read protocol entity.

public <T extends Resultset> T
readAllResults(int maxRows, boolean streamResults, NativePacketPayload resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory)

public final NativePacketPayload
readMessage(NativePacketPayload
Message instance to read into, may be null
reuse
)

Implements com.mysql.cj.protocol.Protocol.readMessage.

Read one message from the MySQL server into the reusable buffer if provided or into the new one.

public ColumnDefinition
public <T extends ProtocolEntity> T

Returns:

T instance
readNextResultset
(T
T instance
currentProtocolEntity
,
int
rows limit
maxRows
,
boolean
whether a stream result should be created
streamResults
,
boolean
true for binary protocol
isBinaryEncoded
,
ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory)

Read next result set from multi-result chain.

public <T extends QueryResult> T
readQueryResult(ResultBuilder<T>
ResultBuilder instance
resultBuilder
)

Implements com.mysql.cj.protocol.Protocol.readQueryResult.

Read messages from server and deliver them to resultBuilder.

public NativeCapabilities
readServerCapabilities()

Implements com.mysql.cj.protocol.Protocol.readServerCapabilities.

Retrieve ServerCapabilities from server.

public final <T> T
readServerStatusForResultSets(NativePacketPayload rowPacket, boolean saveOldStatus)

public void
reclaimLargeReusablePacket()

Don't hold on to overly-large packets

private void
public void
public void
public void
public final void
send(Message packet, int
length of header + payload
packetLen
)

Implements com.mysql.cj.protocol.Protocol.send.

public final NativePacketPayload
sendCommand(Message
a packet pre-loaded with data for the protocol (eg. from a client-side prepared statement). The first byte of this packet is the MySQL protocol 'command' from MysqlDefs
queryPacket
,
boolean
do not call checkErrorPacket() if true
skipCheck
,
int
timeout
timeoutMillis
)

Implements com.mysql.cj.protocol.Protocol.sendCommand.

Send a command to the MySQL server.

public final NativePacketPayload

Returns:

NativePacketPayload
sendFileToServer
(String
the file name to send.
fileName
)

Reads and sends a file to the server for LOAD DATA LOCAL INFILE

public final <
extends Resultset
T extends Resultset
>
T

Returns:

T instance
sendQueryPacket
(Query callingQuery, NativePacketPayload
NativePacketPayload containing query
queryPacket
,
int
rows limit
maxRows
,
boolean
whether a stream result should be created
streamResults
,
ColumnDefinition
use this metadata instead of the one provided on wire
cachedMetadata
,
ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory)

Send a query stored in a packet to the server.

public void
setHadWarnings(boolean hadWarnings)

public void
setLocalInfileInputStream(InputStream
input stream
stream
)

Implements com.mysql.cj.protocol.Protocol.setLocalInfileInputStream.

Sets an InputStream instance that will be used to send data to the MySQL server for a "LOAD DATA LOCAL INFILE" statement rather than a FileInputStream or URLInputStream that represents the path given as an argument to the statement.

public void
public void
setSocketTimeout(int milliseconds)

public void
public void
setWarningCount(int warningCount)

public final void
skipPacket()

Reads and discards a single MySQL packet.

public void
protected boolean
public boolean
versionMeetsMinimum(int major, int minor, int subminor)

Implements com.mysql.cj.protocol.Protocol.versionMeetsMinimum.

Inherited from com.mysql.cj.protocol.AbstractProtocol:
addListenergetAuthenticationProvidergetExceptionInterceptorgetPacketReceivedTimeHoldergetPacketSentTimeHoldergetPropertySetgetQueryTimingUnitsgetSocketConnectioninvokeListenersremoveListenerresetsetPacketReceivedTimeHoldersetPacketSentTimeHoldersetPropertySet