Top Description Inners Methods
com.mysql.cj.protocol

public Interface Protocol<M extends Message>

Known Direct Implementers
com.mysql.cj.protocol.x.XProtocol, com.mysql.cj.protocol.AbstractProtocol
Type Parameters
<M>
Message type
Imports
java.io.IOException, .InputStream, java.util.function.Supplier, com.mysql.cj.MessageBuilder, .QueryResult, .Session, .TransactionEventHandler, com.mysql.cj.conf.PropertySet, com.mysql.cj.exceptions.CJException, .ExceptionInterceptor, com.mysql.cj.protocol.Protocol.ProtocolEventListener.EventType

A protocol provides the facilities to communicate with a MySQL server.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
changeUser(String
DB user name
user
,
String
DB user password
password
,
String
database name
database
)

Re-authenticates as the given user and password

public M

Returns:

a message ready for reading.
checkErrorMessage
()

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

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

Create a new session.

public AuthenticationProvider<M>
public ExceptionInterceptor
public InputStream

Returns:

input stream
getLocalInfileInputStream
()

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

public MessageBuilder<M>
public PacketReceivedTimeHolder
public PacketSentTimeHolder
public PropertySet
public String
public ServerSession
public SocketConnection
public Supplier<ValueEncoder>
public void
init(Session session, SocketConnection socketConnection, PropertySet propertySet, TransactionEventHandler transactionManager)

Init method takes the place of constructor.

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

public <
object extending the ProtocolEntity
T extends ProtocolEntity
>
T

Returns:

ProtocolEntity instance
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
,
M
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, M> protocolEntityFactory)

Read protocol entity.

public M

Returns:

the message from the server.
readMessage
(M
Message instance to read into, may be null
reuse
)

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

public ColumnDefinition
public <
result type
T extends QueryResult
>
T

Returns:

QueryResult
readQueryResult
(ResultBuilder<T>
ResultBuilder instance
resultBuilder
)

Read messages from server and deliver them to resultBuilder.

public ServerCapabilities
readServerCapabilities()

Retrieve ServerCapabilities from server.

public void
reset()

Return Protocol to its initial state right after successful connect.

public void
send(Message
Message instance
message
,
int
length of header + payload
packetLen
)

public M

Returns:

the response packet from the server
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
)

Send a command to the MySQL server.

public void
setLocalInfileInputStream(InputStream
input stream
stream
)

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
public void
public boolean
versionMeetsMinimum(int major, int minor, int subminor)

Method Detail

afterHandshakeback to summary
public void afterHandshake()
beforeHandshakeback to summary
public void beforeHandshake()
changeDatabaseback to summary
public void changeDatabase(String database)
changeUserback to summary
public void changeUser(String user, String password, String database)

Re-authenticates as the given user and password

Parameters
user:String

DB user name

password:String

DB user password

database:String

database name

checkErrorMessageback to summary
public M checkErrorMessage()

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

Returns:M

a message ready for reading.

closeback to summary
public void close() throws IOException
configureTimeZoneback to summary
public void configureTimeZone()
connectback to summary
public void connect(String user, String password, String database)

Create a new session. This generally happens once at the beginning of a connection.

Parameters
user:String

DB user name

password:String

DB user password

database:String

database name

getAuthenticationProviderback to summary
public AuthenticationProvider<M> getAuthenticationProvider()
getExceptionInterceptorback to summary
public ExceptionInterceptor getExceptionInterceptor()
getLocalInfileInputStreamback to summary
public InputStream getLocalInfileInputStream()

Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement. This method returns NULL if no such stream has been set via setLocalInfileInputStream().

Returns:InputStream

input stream

getMessageBuilderback to summary
public MessageBuilder<M> getMessageBuilder()
getPacketReceivedTimeHolderback to summary
public PacketReceivedTimeHolder getPacketReceivedTimeHolder()
getPacketSentTimeHolderback to summary
public PacketSentTimeHolder getPacketSentTimeHolder()
getPropertySetback to summary
public PropertySet getPropertySet()
getQueryTimingUnitsback to summary
public String getQueryTimingUnits()
getServerSessionback to summary
public ServerSession getServerSession()
getSocketConnectionback to summary
public SocketConnection getSocketConnection()
getValueEncoderSupplierback to summary
public Supplier<ValueEncoder> getValueEncoderSupplier(Object obj)
initback to summary
public void init(Session session, SocketConnection socketConnection, PropertySet propertySet, TransactionEventHandler transactionManager)

Init method takes the place of constructor. A constructor should be used unless the encapsulation of ProtocolFactory is necessary.

Parameters
session:Session

Session

socketConnection:SocketConnection

SocketConnection

propertySet:PropertySet

PropertySet

transactionManager:TransactionEventHandler

TransactionEventHandler

initServerSessionback to summary
public void initServerSession()
negotiateSSLConnectionback to summary
public void negotiateSSLConnection()
readback to summary
public <T extends ProtocolEntity> T read(Class<T> requiredClass, ProtocolEntityFactory<T, M> protocolEntityFactory) throws IOException
readback to summary
public <T extends ProtocolEntity> T read(Class<Resultset> requiredClass, int maxRows, boolean streamResults, M resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T, M> protocolEntityFactory) throws IOException

Read protocol entity.

Parameters
<T>
object extending the ProtocolEntity
requiredClass:Class<Resultset>

required Resultset class

maxRows:int

the maximum number of rows to read (-1 means all rows)

streamResults:boolean

should the driver leave the results on the wire, and read them only when needed?

resultPacket:M

the first packet of information in the result set

isBinaryEncoded:boolean

true if the binary protocol is used (for server prepared statements)

metadata:ColumnDefinition

use this metadata instead of the one provided on wire

protocolEntityFactory:ProtocolEntityFactory<T, M>

ProtocolEntityFactory instance

Returns:T

ProtocolEntity instance

Exceptions
IOException:
if an error occurs
readMessageback to summary
public M readMessage(M reuse)

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

Parameters
reuse:M

Message instance to read into, may be null

Returns:M

the message from the server.

readMetadataback to summary
public ColumnDefinition readMetadata()
readQueryResultback to summary
public <T extends QueryResult> T readQueryResult(ResultBuilder<T> resultBuilder)

Read messages from server and deliver them to resultBuilder.

Parameters
<T>
result type
resultBuilder:ResultBuilder<T>

ResultBuilder instance

Returns:T

QueryResult

readServerCapabilitiesback to summary
public ServerCapabilities readServerCapabilities()

Retrieve ServerCapabilities from server.

Returns:ServerCapabilities

ServerCapabilities

resetback to summary
public void reset()

Return Protocol to its initial state right after successful connect.

sendback to summary
public void send(Message message, int packetLen)
Parameters
message:Message

Message instance

packetLen:int

length of header + payload

sendCommandback to summary
public M sendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)

Send a command to the MySQL server.

Parameters
queryPacket: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

skipCheck:boolean

do not call checkErrorPacket() if true

timeoutMillis:int

timeout

Returns:M

the response packet from the server

Exceptions
CJException:
if an I/O error or SQL error occurs
setLocalInfileInputStreamback to summary
public void setLocalInfileInputStream(InputStream stream)

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. This stream will be read to completion upon execution of a "LOAD DATA LOCAL INFILE" statement, and will automatically be closed by the driver, so it needs to be reset before each call to execute*() that would cause the MySQL server to request data to fulfill the request for "LOAD DATA LOCAL INFILE". If this value is set to NULL, the driver will revert to using a FileInputStream or URLInputStream as required.

Parameters
stream:InputStream

input stream

setPacketReceivedTimeHolderback to summary
public void setPacketReceivedTimeHolder(PacketReceivedTimeHolder packetReceivedTimeHolder)
setPacketSentTimeHolderback to summary
public void setPacketSentTimeHolder(PacketSentTimeHolder packetSentTimeHolder)
setPropertySetback to summary
public void setPropertySet(PropertySet propertySet)
versionMeetsMinimumback to summary
public boolean versionMeetsMinimum(int major, int minor, int subminor)
com.mysql.cj.protocol back to summary

public Interface Protocol.ProtocolEventHandler

Known Direct Implementers
com.mysql.cj.protocol.AbstractProtocol

Method Summary

Modifier and TypeMethod and Description
public void
addListener(Protocol.ProtocolEventListener l)

Add listener for this protocol events.

public void
public void

Method Detail

addListenerback to summary
public void addListener(Protocol.ProtocolEventListener l)

Add listener for this protocol events.

Parameters
l:Protocol.ProtocolEventListener

ProtocolEventListener instance.

invokeListenersback to summary
public void invokeListeners(Protocol.ProtocolEventListener.EventType type, Throwable reason)
removeListenerback to summary
public void removeListener(Protocol.ProtocolEventListener l)

Remove protocol listener.

Parameters
l:Protocol.ProtocolEventListener

ProtocolEventListener instance.

com.mysql.cj.protocol back to summary

public Interface Protocol.ProtocolEventListener

Known Direct Implementers
com.mysql.cj.xdevapi.ClientImpl

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

handleEventback to summary
public void handleEvent(Protocol.ProtocolEventListener.EventType type, Object info, Throwable reason)
com.mysql.cj.protocol back to summary

public final Enum Protocol.ProtocolEventListener.EventType

extends Enum<Protocol.ProtocolEventListener.EventType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Protocol.ProtocolEventListener.EventType
public static final Protocol.ProtocolEventListener.EventType

Constructor Summary

AccessConstructor and Description
private

Field Detail

SERVER_CLOSED_SESSIONback to summary
public static final Protocol.ProtocolEventListener.EventType SERVER_CLOSED_SESSION
SERVER_SHUTDOWNback to summary
public static final Protocol.ProtocolEventListener.EventType SERVER_SHUTDOWN

Constructor Detail

EventTypeback to summary
private EventType()

Method Detail

valueOfback to summary
public static Protocol.ProtocolEventListener.EventType valueOf(String name)
valuesback to summary
public static Protocol.ProtocolEventListener.EventType[] values()