Package com.mysql.cj.protocol.a
Class NativeProtocol
java.lang.Object
- All Implemented Interfaces:
RuntimeProperty.RuntimePropertyListener
,Protocol<NativePacketPayload>
public class NativeProtocol extends AbstractProtocol<NativePacketPayload> implements Protocol<NativePacketPayload>, RuntimeProperty.RuntimePropertyListener
-
Field Summary
Fields Modifier and Type Field Description protected static int
COMP_HEADER_LENGTH
protected CompressedPacketSender
compressedPacketSender
Track this to manually shut down.protected boolean
hadWarnings
protected static int
INITIAL_PACKET_SIZE
protected static int
MAX_QUERY_SIZE_TO_EXPLAIN
protected MessageReader<NativePacketHeader,NativePacketPayload>
packetReader
protected MessageSender<NativePacketPayload>
packetSender
protected byte
packetSequence
protected boolean
platformDbCharsetMatches
Does the character set of this connection match the character set of the platformprotected java.util.Map<java.lang.Class<? extends ProtocolEntity>,ProtocolEntityReader<? extends ProtocolEntity,? extends Message>>
PROTOCOL_ENTITY_CLASS_TO_BINARY_READER
protected java.util.Map<java.lang.Class<? extends ProtocolEntity>,ProtocolEntityReader<? extends ProtocolEntity,? extends Message>>
PROTOCOL_ENTITY_CLASS_TO_TEXT_READER
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 anywayprotected NativeServerSession
serverSession
protected NativePacketPayload
sharedSendPacket
protected static int
SSL_REQUEST_LENGTH
protected boolean
useCompression
Fields inherited from class com.mysql.cj.protocol.AbstractProtocol
authProvider, exceptionInterceptor, log, messageBuilder, packetDebugRingBuffer, propertySet, queryTimingUnits, session, socketConnection, transactionManager, useNanosForElapsedTime
-
Constructor Summary
Constructors Constructor Description NativeProtocol(Log logger)
-
Method Summary
Modifier and Type Method Description void
afterHandshake()
void
applyPacketDecorators(MessageSender<NativePacketPayload> sender, MessageReader<NativePacketHeader,NativePacketPayload> messageReader)
Apply optional decorators to configured PacketSender and PacketReader.void
beforeHandshake()
void
changeDatabase(java.lang.String database)
void
changeUser(java.lang.String user, java.lang.String password, java.lang.String database)
Re-authenticates as the given user and passwordNativePacketPayload
checkErrorMessage()
Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for readingvoid
checkErrorMessage(NativePacketPayload resultPacket)
void
checkForCharsetMismatch()
Determines if the database charset is the same as the platform charsetvoid
checkForOutstandingStreamingData()
void
checkTransactionState()
void
clearInputStream()
void
close()
void
configureTimeZone()
Configures the client's timezone if required.void
connect(java.lang.String user, java.lang.String password, java.lang.String database)
Create a new session.java.sql.SQLWarning
convertShowWarningsToSQLWarnings(int warningCountIfKnown, boolean forTruncationOnly)
Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.boolean
doesPlatformDbCharsetMatches()
void
dumpPacketRingBuffer()
void
explainSlowQuery(java.lang.String query, java.lang.String truncatedQuery)
Runs an 'EXPLAIN' on the given query and dumps the results to the logstatic MysqlType
findMysqlType(PropertySet propertySet, int mysqlTypeId, short colFlag, long length, LazyString tableName, LazyString originalTableName, int collationIndex, java.lang.String encoding)
java.lang.StringBuilder
generateQueryCommentBlock(java.lang.StringBuilder buf)
int
getCommandCount()
long
getCurrentTimeNanosOrMillis()
static NativeProtocol
getInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log, TransactionEventHandler transactionManager)
java.io.InputStream
getLocalInfileInputStream()
Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement.MessageBuilder<NativePacketPayload>
getMessageBuilder()
BaseMetricsHolder
getMetricsHolder()
MessageReader<NativePacketHeader,NativePacketPayload>
getPacketReader()
MessageSender<NativePacketPayload>
getPacketSender()
java.lang.String
getPasswordCharacterEncoding()
java.lang.String
getQueryComment()
Returns the comment that will be prepended to all statements sent to the server.java.util.List<QueryInterceptor>
getQueryInterceptors()
NativePacketPayload
getReusablePacket()
NativeServerSession
getServerSession()
NativePacketPayload
getSharedSendPacket()
Returns the packet used for sending data (used by PreparedStatement) with position set to 0.long
getSlowQueryThreshold()
ResultsetRows
getStreamingData()
int
getWarningCount()
boolean
hadWarnings()
void
handlePropertyChange(RuntimeProperty<?> prop)
void
init(Session sess, SocketConnection phConnection, PropertySet propSet, TransactionEventHandler trManager)
Init method takes the place of constructor.void
initServerSession()
<T extends Resultset>
TinvokeQueryInterceptorsPost(java.util.function.Supplier<java.lang.String> sql, Query interceptedQuery, T originalResultSet, boolean forceExecute)
<M extends Message>
MinvokeQueryInterceptorsPost(M queryPacket, M originalResponsePacket, boolean forceExecute)
<T extends Resultset>
TinvokeQueryInterceptorsPre(java.util.function.Supplier<java.lang.String> sql, Query interceptedQuery, boolean forceExecute)
<M extends Message>
MinvokeQueryInterceptorsPre(M queryPacket, boolean forceExecute)
protected boolean
isDataAvailable()
void
negotiateSSLConnection()
Negotiates the SSL communications channel used when connecting to a MySQL server that understands SSL.void
quit()
Log-off of the MySQL server and close the socket.<T extends ProtocolEntity>
Tread(java.lang.Class<Resultset> requiredClass, int maxRows, boolean streamResults, NativePacketPayload resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> protocolEntityFactory)
Read protocol entity.<T extends ProtocolEntity>
Tread(java.lang.Class<T> requiredClass, ProtocolEntityFactory<T,NativePacketPayload> protocolEntityFactory)
<T extends Resultset>
TreadAllResults(int maxRows, boolean streamResults, NativePacketPayload resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)
NativePacketPayload
readMessage(NativePacketPayload reuse)
Read one message from the MySQL server into the reusable buffer if provided or into the new one.ColumnDefinition
readMetadata()
<T extends ProtocolEntity>
TreadNextResultset(T currentProtocolEntity, int maxRows, boolean streamResults, boolean isBinaryEncoded, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)
Read next result set from multi-result chain.<T extends QueryResult>
TreadQueryResult(ResultBuilder<T> resultBuilder)
Read messages from server and deliver them to resultBuilder.NativeCapabilities
readServerCapabilities()
Retrieve ServerCapabilities from server.<T> T
readServerStatusForResultSets(NativePacketPayload rowPacket, boolean saveOldStatus)
void
reclaimLargeReusablePacket()
Don't hold on to overly-large packetsvoid
rejectProtocol(NativePacketPayload msg)
void
releaseResources()
void
scanForAndThrowDataTruncation()
void
send(Message packet, int packetLen)
NativePacketPayload
sendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)
Send a command to the MySQL server.NativePacketPayload
sendFileToServer(java.lang.String fileName)
Reads and sends a file to the server for LOAD DATA LOCAL INFILE<T extends Resultset>
TsendQueryPacket(Query callingQuery, NativePacketPayload queryPacket, int maxRows, boolean streamResults, ColumnDefinition cachedMetadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)
Send a query stored in a packet to the server.<T extends Resultset>
TsendQueryString(Query callingQuery, java.lang.String query, java.lang.String characterEncoding, int maxRows, boolean streamResults, ColumnDefinition cachedMetadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)
Build a query packet from the given string and send it to the server.void
setHadWarnings(boolean hadWarnings)
void
setLocalInfileInputStream(java.io.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.void
setQueryComment(java.lang.String comment)
Sets the comment that will be prepended to all statements sent to the server.void
setQueryInterceptors(java.util.List<QueryInterceptor> queryInterceptors)
void
setSocketTimeout(int milliseconds)
void
setStreamingData(ResultsetRows streamingData)
void
setWarningCount(int warningCount)
void
skipPacket()
Reads and discards a single MySQL packet from the input stream.void
unsetStreamingData(ResultsetRows streamer)
protected boolean
useNanosForElapsedTime()
boolean
versionMeetsMinimum(int major, int minor, int subminor)
Methods inherited from class com.mysql.cj.protocol.AbstractProtocol
getAuthenticationProvider, getExceptionInterceptor, getPacketReceivedTimeHolder, getPacketSentTimeHolder, getPropertySet, getQueryTimingUnits, getSocketConnection, reset, setPacketReceivedTimeHolder, setPacketSentTimeHolder, setPropertySet
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.protocol.Protocol
getAuthenticationProvider, getExceptionInterceptor, getPacketReceivedTimeHolder, getPacketSentTimeHolder, getPropertySet, getQueryTimingUnits, getSocketConnection, reset, setPacketReceivedTimeHolder, setPacketSentTimeHolder, setPropertySet
-
Field Details
-
INITIAL_PACKET_SIZE
protected static final int INITIAL_PACKET_SIZE- See Also:
- Constant Field Values
-
COMP_HEADER_LENGTH
protected static final int COMP_HEADER_LENGTH- See Also:
- Constant Field Values
-
MAX_QUERY_SIZE_TO_EXPLAIN
protected static final int MAX_QUERY_SIZE_TO_EXPLAIN- See Also:
- Constant Field Values
-
SSL_REQUEST_LENGTH
protected static final int SSL_REQUEST_LENGTH- See Also:
- Constant Field Values
-
packetSender
-
packetReader
-
serverSession
-
compressedPacketSender
Track this to manually shut down. -
sharedSendPacket
-
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 -
packetSequence
protected byte packetSequence -
useCompression
protected boolean useCompression -
hadWarnings
protected boolean hadWarnings -
PROTOCOL_ENTITY_CLASS_TO_TEXT_READER
protected java.util.Map<java.lang.Class<? extends ProtocolEntity>,ProtocolEntityReader<? extends ProtocolEntity,? extends Message>> PROTOCOL_ENTITY_CLASS_TO_TEXT_READER -
PROTOCOL_ENTITY_CLASS_TO_BINARY_READER
protected java.util.Map<java.lang.Class<? extends ProtocolEntity>,ProtocolEntityReader<? extends ProtocolEntity,? extends Message>> PROTOCOL_ENTITY_CLASS_TO_BINARY_READER -
platformDbCharsetMatches
protected boolean platformDbCharsetMatchesDoes the character set of this connection match the character set of the platform
-
-
Constructor Details
-
Method Details
-
getInstance
public static NativeProtocol getInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log, TransactionEventHandler transactionManager) -
init
public void init(Session sess, SocketConnection phConnection, PropertySet propSet, TransactionEventHandler trManager)Description copied from interface:Protocol
Init method takes the place of constructor. A constructor should be used unless the encapsulation of ProtocolFactory is necessary.- Specified by:
init
in interfaceProtocol<NativePacketPayload>
- Overrides:
init
in classAbstractProtocol<NativePacketPayload>
- Parameters:
sess
-Session
phConnection
-SocketConnection
propSet
-PropertySet
trManager
-TransactionEventHandler
-
getMessageBuilder
- Specified by:
getMessageBuilder
in interfaceProtocol<NativePacketPayload>
- Overrides:
getMessageBuilder
in classAbstractProtocol<NativePacketPayload>
-
getPacketSender
-
getPacketReader
-
negotiateSSLConnection
public void negotiateSSLConnection()Negotiates the SSL communications channel used when connecting to a MySQL server that understands SSL.- Specified by:
negotiateSSLConnection
in interfaceProtocol<NativePacketPayload>
-
rejectProtocol
-
beforeHandshake
public void beforeHandshake()- Specified by:
beforeHandshake
in interfaceProtocol<NativePacketPayload>
-
afterHandshake
public void afterHandshake()- Specified by:
afterHandshake
in interfaceProtocol<NativePacketPayload>
-
handlePropertyChange
- Specified by:
handlePropertyChange
in interfaceRuntimeProperty.RuntimePropertyListener
-
applyPacketDecorators
public void applyPacketDecorators(MessageSender<NativePacketPayload> sender, MessageReader<NativePacketHeader,NativePacketPayload> messageReader)Apply optional decorators to configured PacketSender and PacketReader.- Parameters:
sender
-MessageSender
messageReader
-MessageReader
-
readServerCapabilities
Description copied from interface:Protocol
Retrieve ServerCapabilities from server.- Specified by:
readServerCapabilities
in interfaceProtocol<NativePacketPayload>
- Returns:
ServerCapabilities
-
getServerSession
- Specified by:
getServerSession
in interfaceProtocol<NativePacketPayload>
-
changeDatabase
public void changeDatabase(java.lang.String database)- Specified by:
changeDatabase
in interfaceProtocol<NativePacketPayload>
-
readMessage
Description copied from interface:Protocol
Read one message from the MySQL server into the reusable buffer if provided or into the new one.- Specified by:
readMessage
in interfaceProtocol<NativePacketPayload>
- Parameters:
reuse
-Message
instance to read into, may be null- Returns:
- the message from the server.
-
send
- Specified by:
send
in interfaceProtocol<NativePacketPayload>
- Parameters:
packet
-Message
packetLen
- length of header + payload
-
sendCommand
public final NativePacketPayload sendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)Description copied from interface:Protocol
Send a command to the MySQL server.- Specified by:
sendCommand
in interfaceProtocol<NativePacketPayload>
- Parameters:
queryPacket
- 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 MysqlDefsskipCheck
- do not call checkErrorPacket() if truetimeoutMillis
- timeout- Returns:
- the response packet from the server
-
checkTransactionState
public void checkTransactionState() -
checkErrorMessage
Description copied from interface:Protocol
Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for reading- Specified by:
checkErrorMessage
in interfaceProtocol<NativePacketPayload>
- Returns:
- a message ready for reading.
-
checkErrorMessage
-
clearInputStream
public void clearInputStream() -
reclaimLargeReusablePacket
public void reclaimLargeReusablePacket()Don't hold on to overly-large packets -
sendQueryString
public final <T extends Resultset> T sendQueryString(Query callingQuery, java.lang.String query, java.lang.String characterEncoding, int maxRows, boolean streamResults, ColumnDefinition cachedMetadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory) throws java.io.IOExceptionBuild a query packet from the given string and send it to the server.- Type Parameters:
T
- extendsResultset
- Parameters:
callingQuery
-Query
query
- query stringcharacterEncoding
- Java encoding namemaxRows
- rows limitstreamResults
- whether a stream result should be createdcachedMetadata
- use this metadata instead of the one provided on wireresultSetFactory
-ProtocolEntityFactory
- Returns:
- T instance
- Throws:
java.io.IOException
- if an i/o error occurs
-
sendQueryPacket
public final <T extends Resultset> T sendQueryPacket(Query callingQuery, NativePacketPayload queryPacket, int maxRows, boolean streamResults, ColumnDefinition cachedMetadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory) throws java.io.IOExceptionSend a query stored in a packet to the server.- Type Parameters:
T
- extendsResultset
- Parameters:
callingQuery
-Query
queryPacket
-NativePacketPayload
containing querymaxRows
- rows limitstreamResults
- whether a stream result should be createdcachedMetadata
- use this metadata instead of the one provided on wireresultSetFactory
-ProtocolEntityFactory
- Returns:
- T instance
- Throws:
java.io.IOException
- if an i/o error occurs
-
invokeQueryInterceptorsPre
-
invokeQueryInterceptorsPre
- Type Parameters:
M
- extendsMessage
- Parameters:
queryPacket
-NativePacketPayload
containing queryforceExecute
- currently ignored- Returns:
- M instance
-
invokeQueryInterceptorsPost
-
invokeQueryInterceptorsPost
public <M extends Message> M invokeQueryInterceptorsPost(M queryPacket, M originalResponsePacket, boolean forceExecute)- Type Parameters:
M
- extendsMessage
- Parameters:
queryPacket
-NativePacketPayload
containing queryoriginalResponsePacket
-NativePacketPayload
containing responseforceExecute
- currently ignored- Returns:
- T instance
-
getCurrentTimeNanosOrMillis
public long getCurrentTimeNanosOrMillis() -
hadWarnings
public boolean hadWarnings() -
setHadWarnings
public void setHadWarnings(boolean hadWarnings) -
explainSlowQuery
public void explainSlowQuery(java.lang.String query, java.lang.String truncatedQuery)Runs an 'EXPLAIN' on the given query and dumps the results to the log- Parameters:
query
- full query stringtruncatedQuery
- query string truncated for profiling
-
skipPacket
public final void skipPacket()Reads and discards a single MySQL packet from the input stream.- Throws:
CJException
- if the network fails while skipping the packet.
-
quit
public final void quit()Log-off of the MySQL server and close the socket. -
getSharedSendPacket
Returns the packet used for sending data (used by PreparedStatement) with position set to 0. Guarded by external synchronization on a mutex.- Returns:
- A packet to send data with
-
changeUser
public void changeUser(java.lang.String user, java.lang.String password, java.lang.String database)Re-authenticates as the given user and password- Specified by:
changeUser
in interfaceProtocol<NativePacketPayload>
- Parameters:
user
- user namepassword
- passworddatabase
- database name
-
checkForCharsetMismatch
public void checkForCharsetMismatch()Determines if the database charset is the same as the platform charset -
useNanosForElapsedTime
protected boolean useNanosForElapsedTime() -
getSlowQueryThreshold
public long getSlowQueryThreshold() -
getCommandCount
public int getCommandCount() -
setQueryInterceptors
-
getQueryInterceptors
-
setSocketTimeout
public void setSocketTimeout(int milliseconds) -
releaseResources
public void releaseResources() -
connect
public void connect(java.lang.String user, java.lang.String password, java.lang.String database)Description copied from interface:Protocol
Create a new session. This generally happens once at the beginning of a connection.- Specified by:
connect
in interfaceProtocol<NativePacketPayload>
- Parameters:
user
- DB user namepassword
- DB user passworddatabase
- database name
-
isDataAvailable
protected boolean isDataAvailable() -
getReusablePacket
-
getWarningCount
public int getWarningCount() -
setWarningCount
public void setWarningCount(int warningCount) -
dumpPacketRingBuffer
public void dumpPacketRingBuffer() -
doesPlatformDbCharsetMatches
public boolean doesPlatformDbCharsetMatches() -
getPasswordCharacterEncoding
public java.lang.String getPasswordCharacterEncoding()- Specified by:
getPasswordCharacterEncoding
in interfaceProtocol<NativePacketPayload>
-
versionMeetsMinimum
public boolean versionMeetsMinimum(int major, int minor, int subminor)- Specified by:
versionMeetsMinimum
in interfaceProtocol<NativePacketPayload>
-
findMysqlType
public static MysqlType findMysqlType(PropertySet propertySet, int mysqlTypeId, short colFlag, long length, LazyString tableName, LazyString originalTableName, int collationIndex, java.lang.String encoding) -
read
public <T extends ProtocolEntity> T read(java.lang.Class<T> requiredClass, ProtocolEntityFactory<T,NativePacketPayload> protocolEntityFactory) throws java.io.IOException- Specified by:
read
in interfaceProtocol<NativePacketPayload>
- Throws:
java.io.IOException
-
read
public <T extends ProtocolEntity> T read(java.lang.Class<Resultset> requiredClass, int maxRows, boolean streamResults, NativePacketPayload resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> protocolEntityFactory) throws java.io.IOExceptionDescription copied from interface:Protocol
Read protocol entity.- Specified by:
read
in interfaceProtocol<NativePacketPayload>
- Type Parameters:
T
- object extending theProtocolEntity
- Parameters:
requiredClass
- required Resultset classmaxRows
- the maximum number of rows to read (-1 means all rows)streamResults
- should the driver leave the results on the wire, and read them only when needed?resultPacket
- the first packet of information in the result setisBinaryEncoded
- true if the binary protocol is used (for server prepared statements)metadata
- use this metadata instead of the one provided on wireprotocolEntityFactory
-ProtocolEntityFactory
instance- Returns:
ProtocolEntity
instance- Throws:
java.io.IOException
- if an error occurs
-
readNextResultset
public <T extends ProtocolEntity> T readNextResultset(T currentProtocolEntity, int maxRows, boolean streamResults, boolean isBinaryEncoded, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory) throws java.io.IOExceptionRead next result set from multi-result chain.- Type Parameters:
T
- extendsProtocolEntity
- Parameters:
currentProtocolEntity
- T instancemaxRows
- rows limitstreamResults
- whether a stream result should be createdisBinaryEncoded
- true for binary protocolresultSetFactory
-ProtocolEntityFactory
- Returns:
- T instance
- Throws:
java.io.IOException
- if an i/o error occurs
-
readAllResults
public <T extends Resultset> T readAllResults(int maxRows, boolean streamResults, NativePacketPayload resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory) throws java.io.IOException- Throws:
java.io.IOException
-
readServerStatusForResultSets
public final <T> T readServerStatusForResultSets(NativePacketPayload rowPacket, boolean saveOldStatus) -
readQueryResult
Description copied from interface:Protocol
Read messages from server and deliver them to resultBuilder.- Specified by:
readQueryResult
in interfaceProtocol<NativePacketPayload>
- Type Parameters:
T
- result type- Parameters:
resultBuilder
-ResultBuilder
instance- Returns:
QueryResult
-
getLocalInfileInputStream
public java.io.InputStream getLocalInfileInputStream()Description copied from interface:Protocol
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().- Specified by:
getLocalInfileInputStream
in interfaceProtocol<NativePacketPayload>
- Returns:
- input stream
-
setLocalInfileInputStream
public void setLocalInfileInputStream(java.io.InputStream stream)Description copied from interface:Protocol
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.- Specified by:
setLocalInfileInputStream
in interfaceProtocol<NativePacketPayload>
- Parameters:
stream
- input stream
-
sendFileToServer
Reads and sends a file to the server for LOAD DATA LOCAL INFILE- Parameters:
fileName
- the file name to send.- Returns:
- NativePacketPayload
-
getStreamingData
-
setStreamingData
-
checkForOutstandingStreamingData
public void checkForOutstandingStreamingData() -
unsetStreamingData
-
scanForAndThrowDataTruncation
public void scanForAndThrowDataTruncation() -
generateQueryCommentBlock
public java.lang.StringBuilder generateQueryCommentBlock(java.lang.StringBuilder buf) -
getMetricsHolder
-
getQueryComment
public java.lang.String getQueryComment()Description copied from interface:Protocol
Returns the comment that will be prepended to all statements sent to the server.- Specified by:
getQueryComment
in interfaceProtocol<NativePacketPayload>
- Returns:
- query comment string
-
setQueryComment
public void setQueryComment(java.lang.String comment)Description copied from interface:Protocol
Sets the comment that will be prepended to all statements sent to the server. Do not use slash-star or star-slash tokens in the comment as these will be added by the driver itself.- Specified by:
setQueryComment
in interfaceProtocol<NativePacketPayload>
- Parameters:
comment
- query comment string
-
convertShowWarningsToSQLWarnings
public java.sql.SQLWarning convertShowWarningsToSQLWarnings(int warningCountIfKnown, boolean forTruncationOnly)Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances. If 'forTruncationOnly' is true, only looks for truncation warnings, and actually throws DataTruncation as an exception.- Parameters:
warningCountIfKnown
- the warning count (if known), otherwise set it to 0.forTruncationOnly
- if this method should only scan for data truncation warnings- Returns:
- the SQLWarning chain (or null if no warnings)
-
readMetadata
- Specified by:
readMetadata
in interfaceProtocol<NativePacketPayload>
-
close
public void close() throws java.io.IOException- Specified by:
close
in interfaceProtocol<NativePacketPayload>
- Throws:
java.io.IOException
-
configureTimeZone
public void configureTimeZone()Configures the client's timezone if required.- Specified by:
configureTimeZone
in interfaceProtocol<NativePacketPayload>
- Throws:
CJException
- if the timezone the server is configured to use can't be mapped to a Java timezone.
-
initServerSession
public void initServerSession()- Specified by:
initServerSession
in interfaceProtocol<NativePacketPayload>
-