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 intCOMP_HEADER_LENGTHprotected CompressedPacketSendercompressedPacketSenderTrack this to manually shut down.protected booleanhadWarningsprotected static intINITIAL_PACKET_SIZEprotected static intMAX_QUERY_SIZE_TO_EXPLAINprotected MessageReader<NativePacketHeader,NativePacketPayload>packetReaderprotected MessageSender<NativePacketPayload>packetSenderprotected bytepacketSequenceprotected booleanplatformDbCharsetMatchesDoes 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_READERprotected java.util.Map<java.lang.Class<? extends ProtocolEntity>,ProtocolEntityReader<? extends ProtocolEntity,? extends Message>>PROTOCOL_ENTITY_CLASS_TO_TEXT_READERprotected NativePacketPayloadreusablePacketUse this when reading in rows to avoid thousands of new() calls, because the byte arrays just get copied out of the packet anywayprotected NativeServerSessionserverSessionprotected NativePacketPayloadsharedSendPacketprotected static intSSL_REQUEST_LENGTHprotected booleanuseCompressionFields 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 voidafterHandshake()voidapplyPacketDecorators(MessageSender<NativePacketPayload> sender, MessageReader<NativePacketHeader,NativePacketPayload> messageReader)Apply optional decorators to configured PacketSender and PacketReader.voidbeforeHandshake()voidchangeDatabase(java.lang.String database)voidchangeUser(java.lang.String user, java.lang.String password, java.lang.String database)Re-authenticates as the given user and passwordNativePacketPayloadcheckErrorMessage()Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for readingvoidcheckErrorMessage(NativePacketPayload resultPacket)voidcheckForCharsetMismatch()Determines if the database charset is the same as the platform charsetvoidcheckForOutstandingStreamingData()voidcheckTransactionState()voidclearInputStream()voidclose()voidconfigureTimeZone()Configures the client's timezone if required.voidconnect(java.lang.String user, java.lang.String password, java.lang.String database)Create a new session.java.sql.SQLWarningconvertShowWarningsToSQLWarnings(int warningCountIfKnown, boolean forTruncationOnly)Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.booleandoesPlatformDbCharsetMatches()voiddumpPacketRingBuffer()voidexplainSlowQuery(java.lang.String query, java.lang.String truncatedQuery)Runs an 'EXPLAIN' on the given query and dumps the results to the logstatic MysqlTypefindMysqlType(PropertySet propertySet, int mysqlTypeId, short colFlag, long length, LazyString tableName, LazyString originalTableName, int collationIndex, java.lang.String encoding)java.lang.StringBuildergenerateQueryCommentBlock(java.lang.StringBuilder buf)intgetCommandCount()longgetCurrentTimeNanosOrMillis()static NativeProtocolgetInstance(Session session, SocketConnection socketConnection, PropertySet propertySet, Log log, TransactionEventHandler transactionManager)java.io.InputStreamgetLocalInfileInputStream()Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement.MessageBuilder<NativePacketPayload>getMessageBuilder()BaseMetricsHoldergetMetricsHolder()MessageReader<NativePacketHeader,NativePacketPayload>getPacketReader()MessageSender<NativePacketPayload>getPacketSender()java.lang.StringgetPasswordCharacterEncoding()java.lang.StringgetQueryComment()Returns the comment that will be prepended to all statements sent to the server.java.util.List<QueryInterceptor>getQueryInterceptors()NativePacketPayloadgetReusablePacket()NativeServerSessiongetServerSession()NativePacketPayloadgetSharedSendPacket()Returns the packet used for sending data (used by PreparedStatement) with position set to 0.longgetSlowQueryThreshold()ResultsetRowsgetStreamingData()intgetWarningCount()booleanhadWarnings()voidhandlePropertyChange(RuntimeProperty<?> prop)voidinit(Session sess, SocketConnection phConnection, PropertySet propSet, TransactionEventHandler trManager)Init method takes the place of constructor.voidinitServerSession()<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 booleanisDataAvailable()voidnegotiateSSLConnection()Negotiates the SSL communications channel used when connecting to a MySQL server that understands SSL.voidquit()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)NativePacketPayloadreadMessage(NativePacketPayload reuse)Read one message from the MySQL server into the reusable buffer if provided or into the new one.ColumnDefinitionreadMetadata()<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.NativeCapabilitiesreadServerCapabilities()Retrieve ServerCapabilities from server.<T> TreadServerStatusForResultSets(NativePacketPayload rowPacket, boolean saveOldStatus)voidreclaimLargeReusablePacket()Don't hold on to overly-large packetsvoidrejectProtocol(NativePacketPayload msg)voidreleaseResources()voidscanForAndThrowDataTruncation()voidsend(Message packet, int packetLen)NativePacketPayloadsendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)Send a command to the MySQL server.NativePacketPayloadsendFileToServer(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.voidsetHadWarnings(boolean hadWarnings)voidsetLocalInfileInputStream(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.voidsetQueryComment(java.lang.String comment)Sets the comment that will be prepended to all statements sent to the server.voidsetQueryInterceptors(java.util.List<QueryInterceptor> queryInterceptors)voidsetSocketTimeout(int milliseconds)voidsetStreamingData(ResultsetRows streamingData)voidsetWarningCount(int warningCount)voidskipPacket()Reads and discards a single MySQL packet from the input stream.voidunsetStreamingData(ResultsetRows streamer)protected booleanuseNanosForElapsedTime()booleanversionMeetsMinimum(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, setPropertySetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ProtocolInit method takes the place of constructor. A constructor should be used unless the encapsulation of ProtocolFactory is necessary.- Specified by:
initin interfaceProtocol<NativePacketPayload>- Overrides:
initin classAbstractProtocol<NativePacketPayload>- Parameters:
sess-SessionphConnection-SocketConnectionpropSet-PropertySettrManager-TransactionEventHandler
-
getMessageBuilder
- Specified by:
getMessageBuilderin interfaceProtocol<NativePacketPayload>- Overrides:
getMessageBuilderin 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:
negotiateSSLConnectionin interfaceProtocol<NativePacketPayload>
-
rejectProtocol
-
beforeHandshake
public void beforeHandshake()- Specified by:
beforeHandshakein interfaceProtocol<NativePacketPayload>
-
afterHandshake
public void afterHandshake()- Specified by:
afterHandshakein interfaceProtocol<NativePacketPayload>
-
handlePropertyChange
- Specified by:
handlePropertyChangein interfaceRuntimeProperty.RuntimePropertyListener
-
applyPacketDecorators
public void applyPacketDecorators(MessageSender<NativePacketPayload> sender, MessageReader<NativePacketHeader,NativePacketPayload> messageReader)Apply optional decorators to configured PacketSender and PacketReader.- Parameters:
sender-MessageSendermessageReader-MessageReader
-
readServerCapabilities
Description copied from interface:ProtocolRetrieve ServerCapabilities from server.- Specified by:
readServerCapabilitiesin interfaceProtocol<NativePacketPayload>- Returns:
ServerCapabilities
-
getServerSession
- Specified by:
getServerSessionin interfaceProtocol<NativePacketPayload>
-
changeDatabase
public void changeDatabase(java.lang.String database)- Specified by:
changeDatabasein interfaceProtocol<NativePacketPayload>
-
readMessage
Description copied from interface:ProtocolRead one message from the MySQL server into the reusable buffer if provided or into the new one.- Specified by:
readMessagein interfaceProtocol<NativePacketPayload>- Parameters:
reuse-Messageinstance to read into, may be null- Returns:
- the message from the server.
-
send
- Specified by:
sendin interfaceProtocol<NativePacketPayload>- Parameters:
packet-MessagepacketLen- length of header + payload
-
sendCommand
public final NativePacketPayload sendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)Description copied from interface:ProtocolSend a command to the MySQL server.- Specified by:
sendCommandin 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:ProtocolRead one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for reading- Specified by:
checkErrorMessagein 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-Queryquery- 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-QueryqueryPacket-NativePacketPayloadcontaining 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-NativePacketPayloadcontaining 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-NativePacketPayloadcontaining queryoriginalResponsePacket-NativePacketPayloadcontaining 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:
changeUserin 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:ProtocolCreate a new session. This generally happens once at the beginning of a connection.- Specified by:
connectin 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:
getPasswordCharacterEncodingin interfaceProtocol<NativePacketPayload>
-
versionMeetsMinimum
public boolean versionMeetsMinimum(int major, int minor, int subminor)- Specified by:
versionMeetsMinimumin 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:
readin 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:ProtocolRead protocol entity.- Specified by:
readin 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-ProtocolEntityFactoryinstance- Returns:
ProtocolEntityinstance- 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:ProtocolRead messages from server and deliver them to resultBuilder.- Specified by:
readQueryResultin interfaceProtocol<NativePacketPayload>- Type Parameters:
T- result type- Parameters:
resultBuilder-ResultBuilderinstance- Returns:
QueryResult
-
getLocalInfileInputStream
public java.io.InputStream getLocalInfileInputStream()Description copied from interface:ProtocolReturns 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:
getLocalInfileInputStreamin interfaceProtocol<NativePacketPayload>- Returns:
- input stream
-
setLocalInfileInputStream
public void setLocalInfileInputStream(java.io.InputStream stream)Description copied from interface:ProtocolSets 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:
setLocalInfileInputStreamin 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:ProtocolReturns the comment that will be prepended to all statements sent to the server.- Specified by:
getQueryCommentin interfaceProtocol<NativePacketPayload>- Returns:
- query comment string
-
setQueryComment
public void setQueryComment(java.lang.String comment)Description copied from interface:ProtocolSets 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:
setQueryCommentin 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:
readMetadatain interfaceProtocol<NativePacketPayload>
-
close
public void close() throws java.io.IOException- Specified by:
closein interfaceProtocol<NativePacketPayload>- Throws:
java.io.IOException
-
configureTimeZone
public void configureTimeZone()Configures the client's timezone if required.- Specified by:
configureTimeZonein 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:
initServerSessionin interfaceProtocol<NativePacketPayload>
-