接口 Protocol<M extends Message>
-
- 类型参数:
M- Message type
public interface Protocol<M extends Message>A protocol provides the facilities to communicate with a MySQL server.
-
-
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static interfaceProtocol.ProtocolEventHandlerstatic interfaceProtocol.ProtocolEventListener
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidafterHandshake()voidbeforeHandshake()voidchangeDatabase(String database)voidchangeUser(String user, String password, String database)Re-authenticates as the given user and passwordMcheckErrorMessage()Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for readingvoidclose()voidconfigureTimeZone()voidconnect(String user, String password, String database)Create a new session.AuthenticationProvider<M>getAuthenticationProvider()ExceptionInterceptorgetExceptionInterceptor()InputStreamgetLocalInfileInputStream()Returns the InputStream instance that will be used to send data in response to a "LOAD DATA LOCAL INFILE" statement.MessageBuilder<M>getMessageBuilder()PacketReceivedTimeHoldergetPacketReceivedTimeHolder()PacketSentTimeHoldergetPacketSentTimeHolder()PropertySetgetPropertySet()StringgetQueryComment()Returns the comment that will be prepended to all statements sent to the server.StringgetQueryTimingUnits()ServerSessiongetServerSession()SocketConnectiongetSocketConnection()java.util.function.Supplier<ValueEncoder>getValueEncoderSupplier(Object obj)voidinit(Session session, SocketConnection socketConnection, PropertySet propertySet, TransactionEventHandler transactionManager)Init method takes the place of constructor.voidinitServerSession()voidnegotiateSSLConnection()<T extends ProtocolEntity>
Tread(Class<Resultset> requiredClass, int maxRows, boolean streamResults, M resultPacket, boolean isBinaryEncoded, ColumnDefinition metadata, ProtocolEntityFactory<T,M> protocolEntityFactory)Read protocol entity.<T extends ProtocolEntity>
Tread(Class<T> requiredClass, ProtocolEntityFactory<T,M> protocolEntityFactory)MreadMessage(M reuse)Read one message from the MySQL server into the reusable buffer if provided or into the new one.ColumnDefinitionreadMetadata()<T extends QueryResult>
TreadQueryResult(ResultBuilder<T> resultBuilder)Read messages from server and deliver them to resultBuilder.ServerCapabilitiesreadServerCapabilities()Retrieve ServerCapabilities from server.voidreset()Return Protocol to its initial state right after successful connect.voidsend(Message message, int packetLen)MsendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)Send a command to the MySQL server.voidsetLocalInfileInputStream(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.voidsetPacketReceivedTimeHolder(PacketReceivedTimeHolder packetReceivedTimeHolder)voidsetPacketSentTimeHolder(PacketSentTimeHolder packetSentTimeHolder)voidsetPropertySet(PropertySet propertySet)voidsetQueryComment(String comment)Sets the comment that will be prepended to all statements sent to the server.booleanversionMeetsMinimum(int major, int minor, int subminor)
-
-
-
方法详细资料
-
init
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.- 参数:
session-SessionsocketConnection-SocketConnectionpropertySet-PropertySettransactionManager-TransactionEventHandler
-
getPropertySet
PropertySet getPropertySet()
-
setPropertySet
void setPropertySet(PropertySet propertySet)
-
getMessageBuilder
MessageBuilder<M> getMessageBuilder()
-
readServerCapabilities
ServerCapabilities readServerCapabilities()
Retrieve ServerCapabilities from server.
-
getServerSession
ServerSession getServerSession()
-
getSocketConnection
SocketConnection getSocketConnection()
-
getAuthenticationProvider
AuthenticationProvider<M> getAuthenticationProvider()
-
getExceptionInterceptor
ExceptionInterceptor getExceptionInterceptor()
-
getPacketSentTimeHolder
PacketSentTimeHolder getPacketSentTimeHolder()
-
setPacketSentTimeHolder
void setPacketSentTimeHolder(PacketSentTimeHolder packetSentTimeHolder)
-
getPacketReceivedTimeHolder
PacketReceivedTimeHolder getPacketReceivedTimeHolder()
-
setPacketReceivedTimeHolder
void setPacketReceivedTimeHolder(PacketReceivedTimeHolder packetReceivedTimeHolder)
-
connect
void connect(String user, String password, String database)
Create a new session. This generally happens once at the beginning of a connection.- 参数:
user- DB user namepassword- DB user passworddatabase- database name
-
negotiateSSLConnection
void negotiateSSLConnection()
-
beforeHandshake
void beforeHandshake()
-
afterHandshake
void afterHandshake()
-
changeDatabase
void changeDatabase(String database)
-
changeUser
void changeUser(String user, String password, String database)
Re-authenticates as the given user and password- 参数:
user- DB user namepassword- DB user passworddatabase- database name
-
versionMeetsMinimum
boolean versionMeetsMinimum(int major, int minor, int subminor)
-
readMessage
M readMessage(M reuse)
Read one message from the MySQL server into the reusable buffer if provided or into the new one.- 参数:
reuse-Messageinstance to read into, may be null- 返回:
- the message from the server.
-
checkErrorMessage
M checkErrorMessage()
Read one message from the MySQL server, checks for errors in it, and if none, returns the message, ready for reading- 返回:
- a message ready for reading.
-
send
void send(Message message, int packetLen)
- 参数:
message-MessageinstancepacketLen- length of header + payload
-
readMetadata
ColumnDefinition readMetadata()
-
sendCommand
M sendCommand(Message queryPacket, boolean skipCheck, int timeoutMillis)
Send a command to the MySQL server.- 参数:
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- 返回:
- the response packet from the server
- 抛出:
CJException- if an I/O error or SQL error occurs
-
read
<T extends ProtocolEntity> T read(Class<T> requiredClass, ProtocolEntityFactory<T,M> protocolEntityFactory) throws IOException
- 抛出:
IOException
-
read
<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.- 类型参数:
T- object extending theProtocolEntity- 参数:
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- 返回:
ProtocolEntityinstance- 抛出:
IOException- if an error occurs
-
setLocalInfileInputStream
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.- 参数:
stream- input stream
-
getLocalInfileInputStream
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().- 返回:
- input stream
-
getQueryComment
String getQueryComment()
Returns the comment that will be prepended to all statements sent to the server.- 返回:
- query comment string
-
setQueryComment
void setQueryComment(String comment)
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.- 参数:
comment- query comment string
-
readQueryResult
<T extends QueryResult> T readQueryResult(ResultBuilder<T> resultBuilder)
Read messages from server and deliver them to resultBuilder.- 类型参数:
T- result type- 参数:
resultBuilder-ResultBuilderinstance- 返回:
QueryResult
-
close
void close() throws IOException- 抛出:
IOException
-
configureTimeZone
void configureTimeZone()
-
initServerSession
void initServerSession()
-
reset
void reset()
Return Protocol to its initial state right after successful connect.
-
getQueryTimingUnits
String getQueryTimingUnits()
-
getValueEncoderSupplier
java.util.function.Supplier<ValueEncoder> getValueEncoderSupplier(Object obj)
-
-