Top Description Inners Methods
com.mysql.cj

public Interface Session

Known Direct Implementers
com.mysql.cj.CoreSession
Imports
java.net.SocketAddress, java.util.concurrent.CompletableFuture, java.util.concurrent.locks.Lock, java.util.function.Function, .Predicate, java.util.stream.Collector, com.mysql.cj.conf.HostInfo, .PropertySet, com.mysql.cj.exceptions.CJOperationNotSupportedException, .ExceptionFactory, .ExceptionInterceptor, com.mysql.cj.log.Log, .ProfilerEventHandler, com.mysql.cj.protocol.Message, .Protocol, .ResultBuilder, .ServerSession, com.mysql.cj.result.Row, com.mysql.cj.telemetry.TelemetryHandler

Session exposes logical level which user API uses internally to call Protocol methods. It's a higher-level abstraction than MySQL server session (ServerSession). Protocol and ServerSession methods should never be used directly from user API.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Method Summary

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

Add listener for this session status changes.

public void
changeUser(String
DB user name
userName
,
String
DB user password
password
,
String
database name
database
)

Re-authenticates as the given user and password

public void
forceClose()

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

public DataStoreMetadata
public ExceptionInterceptor
public HostInfo
public String
public Log

Returns:

the Log instance to use for logging messages.
getLog
()

Returns the log mechanism that should be used to log information from/for this Session.

public <M extends Message> MessageBuilder<M>
public String
public ProfilerEventHandler

Returns:

the ProfilerEventHandler object.
getProfilerEventHandler
()

Returns the current ProfilerEventHandler or initializes a new one if none exists.

public PropertySet
public String

Returns:

query comment string
getQueryComment
()

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

public String
public SocketAddress
public ServerSession
public Lock
public TelemetryHandler
public long
public boolean
public boolean
isSetNeededForAutoCommitMode(boolean autoCommitFlag)

public boolean
public default <
Message type
M extends Message
,
Row type
R
,
Result type
RES
>
RES

Returns:

List of rows
query
(M
query message
message
,
Predicate<Row>
row filter function
rowFilter
,
Function<Row, R>
row map function
rowMapper
,
Collector<R, ?, RES>
result collector
collector
)

Synchronously query database with applying rows filtering and mapping.

public default <
Message type
M extends Message
,
Result type
R extends QueryResult
>
R

Returns:

QueryResult object
query
(M
query message
message
,
ResultBuilder<R>
ResultBuilder instance
resultBuilder
)

Synchronously query database.

public default <
Message type
M extends Message
,
Result type
R extends QueryResult
>
CompletableFuture<R>

Returns:

CompletableFuture providing a QueryResult object
queryAsync
(M
query message
message
,
ResultBuilder<R>
ResultBuilder instance
resultBuilder
)

Asynchronously query database.

public void
quit()

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

public void
public void
public void
setQueryComment(String
query comment string
comment
)

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

public void
public boolean

Returns:

true if current server version equal or higher than provided one
versionMeetsMinimum
(int
major version number
major
,
int
minor version number
minor
,
int
sub-minor version number
subminor
)

Does the version of the MySQL server we are connected to meet the given minimums?

Method Detail

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

Add listener for this session status changes.

Parameters
l:Session.SessionEventListener

SessionEventListener instance.

changeUserback to summary
public void changeUser(String userName, String password, String database)

Re-authenticates as the given user and password

Parameters
userName:String

DB user name

password:String

DB user password

database:String

database name

forceCloseback to summary
public void forceClose()

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

getDataStoreMetadataback to summary
public DataStoreMetadata getDataStoreMetadata()
getExceptionInterceptorback to summary
public ExceptionInterceptor getExceptionInterceptor()
getHostInfoback to summary
public HostInfo getHostInfo()
getIdentifierQuoteStringback to summary
public String getIdentifierQuoteString()
getLogback to summary
public Log getLog()

Returns the log mechanism that should be used to log information from/for this Session.

Returns:Log

the Log instance to use for logging messages.

getMessageBuilderback to summary
public <M extends Message> MessageBuilder<M> getMessageBuilder()
getProcessHostback to summary
public String getProcessHost()
getProfilerEventHandlerback to summary
public ProfilerEventHandler getProfilerEventHandler()

Returns the current ProfilerEventHandler or initializes a new one if none exists.

Returns:ProfilerEventHandler

the ProfilerEventHandler object.

getPropertySetback to summary
public PropertySet getPropertySet()
getQueryCommentback to summary
public String getQueryComment()

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

Returns:String

query comment string

getQueryTimingUnitsback to summary
public String getQueryTimingUnits()
getRemoteSocketAddressback to summary
public SocketAddress getRemoteSocketAddress()
getServerSessionback to summary
public ServerSession getServerSession()
getSessionLockback to summary
public Lock getSessionLock()
getTelemetryHandlerback to summary
public TelemetryHandler getTelemetryHandler()
getThreadIdback to summary
public long getThreadId()
isClosedback to summary
public boolean isClosed()
isSetNeededForAutoCommitModeback to summary
public boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)
isSSLEstablishedback to summary
public boolean isSSLEstablished()
queryback to summary
public default <M extends Message, R, RES> RES query(M message, Predicate<Row> rowFilter, Function<Row, R> rowMapper, Collector<R, ?, RES> collector)

Synchronously query database with applying rows filtering and mapping.

Parameters
<M>
Message type
<R>
Row type
<RES>
Result type
message:M

query message

rowFilter:Predicate<Row>

row filter function

rowMapper:Function<Row, R>

row map function

collector:Collector<R, ?, RES>

result collector

Returns:RES

List of rows

queryback to summary
public default <M extends Message, R extends QueryResult> R query(M message, ResultBuilder<R> resultBuilder)

Synchronously query database.

Parameters
<M>
Message type
<R>
Result type
message:M

query message

resultBuilder:ResultBuilder<R>

ResultBuilder instance

Returns:R

QueryResult object

queryAsyncback to summary
public default <M extends Message, R extends QueryResult> CompletableFuture<R> queryAsync(M message, ResultBuilder<R> resultBuilder)

Asynchronously query database.

Parameters
<M>
Message type
<R>
Result type
message:M

query message

resultBuilder:ResultBuilder<R>

ResultBuilder instance

Returns:CompletableFuture<R>

CompletableFuture providing a QueryResult object

quitback to summary
public void quit()

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

removeListenerback to summary
public void removeListener(Session.SessionEventListener l)

Remove session listener.

Parameters
l:Session.SessionEventListener

SessionEventListener instance.

setExceptionInterceptorback to summary
public void setExceptionInterceptor(ExceptionInterceptor exceptionInterceptor)
setQueryCommentback to summary
public 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.

Parameters
comment:String

query comment string

setTelemetryHandlerback to summary
public void setTelemetryHandler(TelemetryHandler telemetryHandler)
versionMeetsMinimumback to summary
public boolean versionMeetsMinimum(int major, int minor, int subminor)

Does the version of the MySQL server we are connected to meet the given minimums?

Parameters
major:int

major version number

minor:int

minor version number

subminor:int

sub-minor version number

Returns:boolean

true if current server version equal or higher than provided one

com.mysql.cj back to summary

public Interface Session.SessionEventListener

Known Direct Implementers
com.mysql.cj.jdbc.ConnectionImpl

Method Summary

Modifier and TypeMethod and Description
public void
handleCleanup(Throwable whyCleanedUp)

public void
public void

Method Detail

handleCleanupback to summary
public void handleCleanup(Throwable whyCleanedUp)
handleNormalCloseback to summary
public void handleNormalClose()
handleReconnectback to summary
public void handleReconnect()