Top Fields Constructors Methods
com.mysql.cj

public Class NativeSession

extends CoreSession
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.IOException, .InputStream, .Serializable, java.lang.ref.WeakReference, java.net.SocketAddress, java.sql.SQLException, java.util.ArrayList, .Collections, .HashMap, .List, .Map, .Properties, .Timer, java.util.concurrent.CopyOnWriteArrayList, java.util.concurrent.locks.Lock, java.util.function.Supplier, java.util.stream.Collectors, .Stream, com.mysql.cj.conf.HostInfo, .PropertyDefinitions.OpenTelemetry, .PropertyKey, .PropertySet, .RuntimeProperty, com.mysql.cj.exceptions.CJCommunicationsException, .CJException, .ConnectionIsClosedException, .ExceptionFactory, .ExceptionInterceptor, .ExceptionInterceptorChain, .MysqlErrorNumbers, .OperationCancelledException, com.mysql.cj.interceptors.QueryInterceptor, com.mysql.cj.log.Log, com.mysql.cj.otel.OpenTelemetryHandler, com.mysql.cj.protocol.ColumnDefinition, .NetworkResources, .ProtocolEntityFactory, .Resultset, .Resultset.Type, .SocketConnection, .SocketFactory, com.mysql.cj.protocol.a.NativeMessageBuilder, .NativePacketPayload, .NativeProtocol, .NativeServerSession, .NativeSocketConnection, .ResultsetFactory, com.mysql.cj.result.Field, .LongValueFactory, .Row, .StringValueFactory, .ValueFactory, com.mysql.cj.telemetry.NoopTelemetryHandler, .TelemetryAttribute, .TelemetryScope, .TelemetrySpan, .TelemetrySpanName, com.mysql.cj.util.StringUtils, .Util

Field Summary

Modifier and TypeField and Description
private transient Timer
private NativeMessageBuilder
private Throwable
forceClosedReason

Why was this session implicitly closed, if known?

private boolean
isClosed

Has this session been closed?

private long
lastQueryFinishedTime

When did the last query finish?

private CopyOnWriteArrayList<WeakReference<Session.SessionEventListener>>
private boolean
needsPing

Does this connection need to be tested?

private String
queryComment

The comment (if any) to prepend to all queries sent to the server (to show up in "SHOW PROCESSLIST")

private static final long
private static final String
private CacheAdapter<String, Map<String, String>>
Inherited from com.mysql.cj.CoreSession:
autoReconnectautoReconnectForPoolscacheServerConfigurationcharacterEncodingconnectionCreationTimeMillisdisconnectOnExpiredPasswordsexceptionInterceptorgatherPerfMetricshostInfologmaintainTimeStatsmessageBuilderNULL_LOGGERpropertySetprotocolsessionMaxRows

Constructor Summary

AccessConstructor and Description
public
NativeSession(HostInfo hostInfo, PropertySet propSet)

Method Summary

Modifier and TypeMethod and Description
public void
addListener(Session.SessionEventListener l)

Overrides com.mysql.cj.CoreSession.addListener.

Implements com.mysql.cj.Session.addListener.

Add listener for this session status changes.

public void
public void
public void
connect(HostInfo hi, String user, String password, String database, int loginTimeout, TransactionEventHandler transactionManager)

private void
public void
public void
public void
public <
extends Resultset
T extends Resultset
>
T

Returns:

a ResultSet holding the results
execSQL
(Query
Query object
callingQuery
,
String
the SQL statement to be executed
query
,
int
rows limit
maxRows
,
NativePacketPayload packet, boolean
whether a stream result should be created
streamResults
,
ProtocolEntityFactory<T, NativePacketPayload> resultSetFactory, ColumnDefinition
use this metadata instead of the one provided on wire
cachedMetadata
,
boolean
is it a batch query
isBatch
)

Send a query to the server.

private String
findProcessHost(long threadId)

public void
forceClose()

Overrides com.mysql.cj.CoreSession.forceClose.

Implements com.mysql.cj.Session.forceClose.

Clobbers the physical network connection and marks this session as closed.

public Timer
public int
public long
public long
public Throwable
public String
public long
public InputStream
public NetworkResources
public String
public NativeProtocol
public String
getQueryComment()

Overrides com.mysql.cj.CoreSession.getQueryComment.

Implements com.mysql.cj.Session.getQueryComment.

Returns the comment that will be prepended to all statements sent to the server.

public SocketAddress
public int
public NativePacketPayload

Returns:

A packet to send data with
getSharedSendPacket
()

Returns the packet used for sending data (used by PreparedStatement) with position set to 0.

public long
public int
public boolean
public void
protected void
public <T extends Resultset> T
invokeQueryInterceptorsPost(Supplier<String> sql, Query interceptedQuery, T originalResultSet, boolean forceExecute)

public <T extends Resultset> T
invokeQueryInterceptorsPre(Supplier<String> sql, Query interceptedQuery, boolean forceExecute)

protected void
public boolean
public boolean
public boolean
public boolean
public boolean
public void
loadServerVariables(Lock
synchronization lock
lock
,
String
driver version string
version
)

Loads pertinent server variables so that the driver can configure itself.

public void
ping(boolean checkForClosedConnection, int timeoutMillis)

public String

Returns:

server variable value
queryServerVariable
(String
server variable name
varName
)

Get the variable value from server.

public void
quit()

Overrides com.mysql.cj.CoreSession.quit.

Implements com.mysql.cj.Session.quit.

Log-off of the MySQL server and close the socket.

public void
public void
public void
setConnectionCreationTimeMillis(long connectionCreationTimeMillis)

public void
setForceClosedReason(Throwable forceClosedReason)

public void
public void
setNeedsPing(boolean needsPing)

public void
setQueryComment(String
query comment string
comment
)

Overrides com.mysql.cj.CoreSession.setQueryComment.

Implements com.mysql.cj.Session.setQueryComment.

Sets the comment that will be prepended to all statements sent to the server.

public void
public void
setSessionMaxRows(int sessionMaxRows)

public void
public void
setSocketTimeout(int milliseconds)

public boolean
public void
shutdownServer()

Used by MiniAdmin to shutdown a MySQL server

Inherited from com.mysql.cj.CoreSession:
changeUsergetDataStoreMetadatagetExceptionInterceptorgetHostInfogetLoggetMessageBuildergetProfilerEventHandlergetPropertySetgetQueryTimingUnitsgetServerSessiongetSessionLockgetTelemetryHandlergetThreadIdsetExceptionInterceptorsetTelemetryHandlerversionMeetsMinimum

Field Detail

cancelTimerback to summary
private transient Timer cancelTimer
commandBuilderback to summary
private NativeMessageBuilder commandBuilder
forceClosedReasonback to summary
private Throwable forceClosedReason

Why was this session implicitly closed, if known? (for diagnostics)

isClosedback to summary
private boolean isClosed

Has this session been closed?

lastQueryFinishedTimeback to summary
private long lastQueryFinishedTime

When did the last query finish?

listenersback to summary
private CopyOnWriteArrayList<WeakReference<Session.SessionEventListener>> listeners
needsPingback to summary
private boolean needsPing

Does this connection need to be tested?

queryCommentback to summary
private String queryComment

The comment (if any) to prepend to all queries sent to the server (to show up in "SHOW PROCESSLIST")

serialVersionUIDback to summary
private static final long serialVersionUID
SERVER_VERSION_STRING_VAR_NAMEback to summary
private static final String SERVER_VERSION_STRING_VAR_NAME
serverConfigCacheback to summary
private CacheAdapter<String, Map<String, String>> serverConfigCache

Constructor Detail

NativeSessionback to summary
public NativeSession(HostInfo hostInfo, PropertySet propSet)

Method Detail

addListenerback to summary
public void addListener(Session.SessionEventListener l)

Overrides com.mysql.cj.CoreSession.addListener.

Implements com.mysql.cj.Session.addListener.

Doc from com.mysql.cj.Session.addListener.

Add listener for this session status changes.

Parameters
l:Session.SessionEventListener

SessionEventListener instance.

Annotations
@Override
checkClosedback to summary
public void checkClosed()
clearInputStreamback to summary
public void clearInputStream()
connectback to summary
public void connect(HostInfo hi, String user, String password, String database, int loginTimeout, TransactionEventHandler transactionManager) throws IOException
createConfigCacheIfNeededback to summary
private void createConfigCacheIfNeeded(Lock lock)
disableMultiQueriesback to summary
public void disableMultiQueries()
dumpPacketRingBufferback to summary
public void dumpPacketRingBuffer()
enableMultiQueriesback to summary
public void enableMultiQueries()
execSQLback to summary
public <T extends Resultset> T execSQL(Query callingQuery, 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 locked block.

Parameters
<T>
extends Resultset
callingQuery:Query

Query object

query:String

the SQL statement to be executed

maxRows:int

rows limit

packet:NativePacketPayload

NativePacketPayload

streamResults:boolean

whether a stream result should be created

resultSetFactory:ProtocolEntityFactory<T, NativePacketPayload>

ProtocolEntityFactory

cachedMetadata:ColumnDefinition

use this metadata instead of the one provided on wire

isBatch:boolean

is it a batch query

Returns:T

a ResultSet holding the results

findProcessHostback to summary
private String findProcessHost(long threadId)
forceCloseback to summary
public void forceClose()

Overrides com.mysql.cj.CoreSession.forceClose.

Implements com.mysql.cj.Session.forceClose.

Doc from com.mysql.cj.Session.forceClose.

Clobbers the physical network connection and marks this session as closed.

Annotations
@Override
getCancelTimerback to summary
public Timer getCancelTimer()
getCommandCountback to summary
public int getCommandCount()
getConnectionCreationTimeMillisback to summary
public long getConnectionCreationTimeMillis()
getCurrentTimeNanosOrMillisback to summary
public long getCurrentTimeNanosOrMillis()
getForceClosedReasonback to summary
public Throwable getForceClosedReason()
getIdentifierQuoteStringback to summary
public String getIdentifierQuoteString()

Overrides com.mysql.cj.CoreSession.getIdentifierQuoteString.

Implements com.mysql.cj.Session.getIdentifierQuoteString.

Annotations
@Override
getIdleForback to summary
public long getIdleFor()
getLocalInfileInputStreamback to summary
public InputStream getLocalInfileInputStream()
getNetworkResourcesback to summary
public NetworkResources getNetworkResources()
getProcessHostback to summary
public String getProcessHost()

Implements com.mysql.cj.Session.getProcessHost.

Annotations
@Override
getProtocolback to summary
public NativeProtocol getProtocol()
getQueryCommentback to summary
public String getQueryComment()

Overrides com.mysql.cj.CoreSession.getQueryComment.

Implements com.mysql.cj.Session.getQueryComment.

Doc from com.mysql.cj.Session.getQueryComment.

Returns the comment that will be prepended to all statements sent to the server.

Returns:String

query comment string

Annotations
@Override
getRemoteSocketAddressback to summary
public SocketAddress getRemoteSocketAddress()

Overrides com.mysql.cj.CoreSession.getRemoteSocketAddress.

Implements com.mysql.cj.Session.getRemoteSocketAddress.

Annotations
@Override
getSessionMaxRowsback to summary
public int getSessionMaxRows()
getSharedSendPacketback to summary
public NativePacketPayload getSharedSendPacket()

Returns the packet used for sending data (used by PreparedStatement) with position set to 0.

Returns:NativePacketPayload

A packet to send data with

getSlowQueryThresholdback to summary
public long getSlowQueryThreshold()
getSocketTimeoutback to summary
public int getSocketTimeout()
hadWarningsback to summary
public boolean hadWarnings()
invokeCleanupListenersback to summary
public void invokeCleanupListeners(Throwable whyCleanedUp)
invokeNormalCloseListenersback to summary
protected void invokeNormalCloseListeners()
invokeQueryInterceptorsPostback to summary
public <T extends Resultset> T invokeQueryInterceptorsPost(Supplier<String> sql, Query interceptedQuery, T originalResultSet, boolean forceExecute)
invokeQueryInterceptorsPreback to summary
public <T extends Resultset> T invokeQueryInterceptorsPre(Supplier<String> sql, Query interceptedQuery, boolean forceExecute)
invokeReconnectListenersback to summary
protected void invokeReconnectListeners()
isClosedback to summary
public boolean isClosed()

Implements com.mysql.cj.Session.isClosed.

Annotations
@Override
isNeedsPingback to summary
public boolean isNeedsPing()
isServerLocalback to summary
public boolean isServerLocal(Session sess)
isSetNeededForAutoCommitModeback to summary
public boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)

Overrides com.mysql.cj.CoreSession.isSetNeededForAutoCommitMode.

Implements com.mysql.cj.Session.isSetNeededForAutoCommitMode.

Annotations
@Override
isSSLEstablishedback to summary
public boolean isSSLEstablished()

Overrides com.mysql.cj.CoreSession.isSSLEstablished.

Implements com.mysql.cj.Session.isSSLEstablished.

Annotations
@Override
loadServerVariablesback to summary
public void loadServerVariables(Lock lock, String version)

Loads pertinent server variables so that the driver can configure itself.

Parameters
lock:Lock

synchronization lock

version:String

driver version string

pingback to summary
public void ping(boolean checkForClosedConnection, int timeoutMillis)
queryServerVariableback to summary
public String queryServerVariable(String varName)

Get the variable value from server.

Parameters
varName:String

server variable name

Returns:String

server variable value

quitback to summary
public void quit()

Overrides com.mysql.cj.CoreSession.quit.

Implements com.mysql.cj.Session.quit.

Doc from com.mysql.cj.Session.quit.

Log-off of the MySQL server and close the socket.

Annotations
@Override
removeListenerback to summary
public void removeListener(Session.SessionEventListener listener)

Overrides com.mysql.cj.CoreSession.removeListener.

Implements com.mysql.cj.Session.removeListener.

Doc from com.mysql.cj.Session.removeListener.

Remove session listener.

Parameters
listener:Session.SessionEventListener

SessionEventListener instance.

Annotations
@Override
resetSessionStateback to summary
public void resetSessionState()
setConnectionCreationTimeMillisback to summary
public void setConnectionCreationTimeMillis(long connectionCreationTimeMillis)
setForceClosedReasonback to summary
public void setForceClosedReason(Throwable forceClosedReason)
setLocalInfileInputStreamback to summary
public void setLocalInfileInputStream(InputStream stream)
setNeedsPingback to summary
public void setNeedsPing(boolean needsPing)
setQueryCommentback to summary
public void setQueryComment(String comment)

Overrides com.mysql.cj.CoreSession.setQueryComment.

Implements com.mysql.cj.Session.setQueryComment.

Doc from com.mysql.cj.Session.setQueryComment.

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.

Parameters
comment:String

query comment string

Annotations
@Override
setQueryInterceptorsback to summary
public void setQueryInterceptors(List<QueryInterceptor> queryInterceptors)
setSessionMaxRowsback to summary
public void setSessionMaxRows(int sessionMaxRows)
setSessionVariablesback to summary
public void setSessionVariables()
setSocketTimeoutback to summary
public void setSocketTimeout(int milliseconds)
shouldInterceptback to summary
public boolean shouldIntercept()
shutdownServerback to summary
public void shutdownServer()

Used by MiniAdmin to shutdown a MySQL server