Package com.mysql.cj
Class NativeSession
java.lang.Object
com.mysql.cj.CoreSession
com.mysql.cj.NativeSession
- All Implemented Interfaces:
Session,java.io.Serializable
public class NativeSession extends CoreSession implements java.io.Serializable
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mysql.cj.Session
Session.SessionEventListener -
Field Summary
Fields inherited from class com.mysql.cj.CoreSession
autoReconnect, autoReconnectForPools, cacheServerConfiguration, characterEncoding, connectionCreationTimeMillis, disconnectOnExpiredPasswords, exceptionInterceptor, gatherPerfMetrics, hostInfo, log, maintainTimeStats, messageBuilder, NULL_LOGGER, propertySet, protocol, sessionMaxRows -
Constructor Summary
Constructors Constructor Description NativeSession(HostInfo hostInfo, PropertySet propSet) -
Method Summary
Modifier and Type Method Description voidaddListener(Session.SessionEventListener l)Add listener for this session status changes.voidbuildCollationMapping()Builds the map needed for 4.1.0 and newer servers that maps field-level charset/collation info to a java character encoding name.voidcheckClosed()voidcheckForCharsetMismatch()Determines if the database charset is the same as the platform charsetvoidclearInputStream()booleanconfigureClientCharacterSet(boolean dontCheckServerMatch)Sets up client character set.voidconnect(HostInfo hi, java.lang.String user, java.lang.String password, java.lang.String database, int loginTimeout, TransactionEventHandler transactionManager)voiddisableMultiQueries()voiddumpPacketRingBuffer()voidenableMultiQueries()<T extends Resultset>
TexecSQL(Query callingQuery, java.lang.String query, int maxRows, NativePacketPayload packet, boolean streamResults, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory, ColumnDefinition cachedMetadata, boolean isBatch)Send a query to the server.voidforceClose()Clobbers the physical network connection and marks this session as closed.java.util.TimergetCancelTimer()intgetCommandCount()longgetConnectionCreationTimeMillis()longgetCurrentTimeNanosOrMillis()java.lang.ThrowablegetForceClosedReason()java.lang.StringgetIdentifierQuoteString()longgetIdleFor()java.io.InputStreamgetLocalInfileInputStream()NetworkResourcesgetNetworkResources()java.lang.StringgetProcessHost()NativeProtocolgetProtocol()java.net.SocketAddressgetRemoteSocketAddress()booleangetRequiresEscapingEncoder()intgetSessionMaxRows()NativePacketPayloadgetSharedSendPacket()Returns the packet used for sending data (used by PreparedStatement) with position set to 0.longgetSlowQueryThreshold()intgetSocketTimeout()booleanhadWarnings()voidinvokeCleanupListeners(java.lang.Throwable whyCleanedUp)protected voidinvokeNormalCloseListeners()<T extends Resultset>
TinvokeQueryInterceptorsPost(java.util.function.Supplier<java.lang.String> sql, Query interceptedQuery, T originalResultSet, boolean forceExecute)<T extends Resultset>
TinvokeQueryInterceptorsPre(java.util.function.Supplier<java.lang.String> sql, Query interceptedQuery, boolean forceExecute)protected voidinvokeReconnectListeners()booleanisClosed()booleanisNeedsPing()booleanisServerLocal(Session sess)booleanisSetNeededForAutoCommitMode(boolean autoCommitFlag)booleanisSSLEstablished()voidloadServerVariables(java.lang.Object syncMutex, java.lang.String version)Loads the result of 'SHOW VARIABLES' into the serverVariables field so that the driver can configure itself.voidping(boolean checkForClosedConnection, int timeoutMillis)java.lang.StringqueryServerVariable(java.lang.String varName)Get the variable value from server.voidquit()Log-off of the MySQL server and close the socket.voidremoveListener(Session.SessionEventListener listener)Remove session listener.NativePacketPayloadsendCommand(NativePacketPayload queryPacket, boolean skipCheck, int timeoutMillis)voidsetConnectionCreationTimeMillis(long connectionCreationTimeMillis)voidsetForceClosedReason(java.lang.Throwable forceClosedReason)voidsetLocalInfileInputStream(java.io.InputStream stream)voidsetNeedsPing(boolean needsPing)voidsetQueryInterceptors(java.util.List<QueryInterceptor> queryInterceptors)voidsetSessionMaxRows(int sessionMaxRows)voidsetSessionVariables()voidsetSocketTimeout(int milliseconds)booleanshouldIntercept()voidshutdownServer()Used by MiniAdmin to shutdown a MySQL serverMethods inherited from class com.mysql.cj.CoreSession
changeUser, getDataStoreMetadata, getExceptionInterceptor, getHostInfo, getLog, getMessageBuilder, getProfilerEventHandler, getPropertySet, getQueryTimingUnits, getServerSession, getThreadId, setExceptionInterceptor, versionMeetsMinimum
-
Constructor Details
-
Method Details
-
connect
public void connect(HostInfo hi, java.lang.String user, java.lang.String password, java.lang.String database, int loginTimeout, TransactionEventHandler transactionManager) throws java.io.IOException- Throws:
java.io.IOException
-
getProtocol
-
quit
public void quit()Description copied from interface:SessionLog-off of the MySQL server and close the socket.- Specified by:
quitin interfaceSession- Overrides:
quitin classCoreSession
-
forceClose
public void forceClose()Description copied from interface:SessionClobbers the physical network connection and marks this session as closed.- Specified by:
forceClosein interfaceSession- Overrides:
forceClosein classCoreSession
-
enableMultiQueries
public void enableMultiQueries() -
disableMultiQueries
public void disableMultiQueries() -
isSetNeededForAutoCommitMode
public boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)- Specified by:
isSetNeededForAutoCommitModein interfaceSession- Overrides:
isSetNeededForAutoCommitModein classCoreSession
-
getSessionMaxRows
public int getSessionMaxRows() -
setSessionMaxRows
public void setSessionMaxRows(int sessionMaxRows) -
setQueryInterceptors
-
isServerLocal
-
shutdownServer
public void shutdownServer()Used by MiniAdmin to shutdown a MySQL server -
setSocketTimeout
public void setSocketTimeout(int milliseconds) -
getSocketTimeout
public int getSocketTimeout() -
checkForCharsetMismatch
public void checkForCharsetMismatch()Determines if the database charset is the same as the platform charset -
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
-
dumpPacketRingBuffer
public void dumpPacketRingBuffer() -
invokeQueryInterceptorsPre
-
invokeQueryInterceptorsPost
-
shouldIntercept
public boolean shouldIntercept() -
getCurrentTimeNanosOrMillis
public long getCurrentTimeNanosOrMillis() -
sendCommand
public final NativePacketPayload sendCommand(NativePacketPayload queryPacket, boolean skipCheck, int timeoutMillis) -
getSlowQueryThreshold
public long getSlowQueryThreshold() -
hadWarnings
public boolean hadWarnings() -
clearInputStream
public void clearInputStream() -
getNetworkResources
-
isSSLEstablished
public boolean isSSLEstablished()- Specified by:
isSSLEstablishedin interfaceSession- Overrides:
isSSLEstablishedin classCoreSession
-
getCommandCount
public int getCommandCount() -
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()- Specified by:
getRemoteSocketAddressin interfaceSession- Overrides:
getRemoteSocketAddressin classCoreSession
-
getLocalInfileInputStream
public java.io.InputStream getLocalInfileInputStream() -
setLocalInfileInputStream
public void setLocalInfileInputStream(java.io.InputStream stream) -
configureClientCharacterSet
public boolean configureClientCharacterSet(boolean dontCheckServerMatch)Sets up client character set. This must be done before any further communication with the server!- Parameters:
dontCheckServerMatch- if true then send the SET NAMES query even if server charset already matches the new value- Returns:
- true if this routine actually configured the client character set, or false if the driver needs to use 'older' methods to detect the character set, as it is connected to a MySQL server older than 4.1.0
- Throws:
CJException- if an exception happens while sending 'SET NAMES' to the server, or the server sends character set information that the client doesn't know about.
-
getRequiresEscapingEncoder
public boolean getRequiresEscapingEncoder() -
loadServerVariables
public void loadServerVariables(java.lang.Object syncMutex, java.lang.String version)Loads the result of 'SHOW VARIABLES' into the serverVariables field so that the driver can configure itself.- Parameters:
syncMutex- synchronization mutexversion- driver version string
-
setSessionVariables
public void setSessionVariables() -
buildCollationMapping
public void buildCollationMapping()Builds the map needed for 4.1.0 and newer servers that maps field-level charset/collation info to a java character encoding name. -
getProcessHost
public java.lang.String getProcessHost()- Specified by:
getProcessHostin interfaceSession
-
queryServerVariable
public java.lang.String queryServerVariable(java.lang.String varName)Get the variable value from server.- Parameters:
varName- server variable name- Returns:
- server variable value
-
execSQL
public <T extends Resultset> T execSQL(Query callingQuery, java.lang.String query, int maxRows, NativePacketPayload packet, boolean streamResults, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory, ColumnDefinition cachedMetadata, boolean isBatch)Send a query to the server. Returns one of the ResultSet objects. To ensure that Statement's queries are serialized, calls to this method should be enclosed in a connection mutex synchronized block.- Type Parameters:
T- extendsResultset- Parameters:
callingQuery-Queryobjectquery- the SQL statement to be executedmaxRows- rows limitpacket-NativePacketPayloadstreamResults- whether a stream result should be createdresultSetFactory-ProtocolEntityFactorycachedMetadata- use this metadata instead of the one provided on wireisBatch- is it a batch query- Returns:
- a ResultSet holding the results
-
getIdleFor
public long getIdleFor() -
isNeedsPing
public boolean isNeedsPing() -
setNeedsPing
public void setNeedsPing(boolean needsPing) -
ping
public void ping(boolean checkForClosedConnection, int timeoutMillis) -
getConnectionCreationTimeMillis
public long getConnectionCreationTimeMillis() -
setConnectionCreationTimeMillis
public void setConnectionCreationTimeMillis(long connectionCreationTimeMillis) -
isClosed
public boolean isClosed() -
checkClosed
public void checkClosed() -
getForceClosedReason
public java.lang.Throwable getForceClosedReason() -
setForceClosedReason
public void setForceClosedReason(java.lang.Throwable forceClosedReason) -
addListener
Description copied from interface:SessionAdd listener for this session status changes.- Specified by:
addListenerin interfaceSession- Overrides:
addListenerin classCoreSession- Parameters:
l-Session.SessionEventListenerinstance.
-
removeListener
Description copied from interface:SessionRemove session listener.- Specified by:
removeListenerin interfaceSession- Overrides:
removeListenerin classCoreSession- Parameters:
listener-Session.SessionEventListenerinstance.
-
invokeNormalCloseListeners
protected void invokeNormalCloseListeners() -
invokeReconnectListeners
protected void invokeReconnectListeners() -
invokeCleanupListeners
public void invokeCleanupListeners(java.lang.Throwable whyCleanedUp) -
getIdentifierQuoteString
public java.lang.String getIdentifierQuoteString()- Specified by:
getIdentifierQuoteStringin interfaceSession- Overrides:
getIdentifierQuoteStringin classCoreSession
-
getCancelTimer
public java.util.Timer getCancelTimer()
-