com.mysql.cj

## Interface Session

    public interface Session

`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 Class Summary

Nested Classes
`static interface` `Session.SessionEventListener`

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`void` `addListener(Session.SessionEventListener l)` Add listener for this session status changes.
`void` `changeUser(String userName, String password, String database)` Re-authenticates as the given user and password
`void` `forceClose()` Clobbers the physical network connection and marks this session as closed.
`DataStoreMetadata` `getDataStoreMetadata()`
`ExceptionInterceptor` `getExceptionInterceptor()`
`HostInfo` `getHostInfo()`
`String` `getIdentifierQuoteString()`
`Log` `getLog()` Returns the log mechanism that should be used to log information from/for this Session.
`<M extends Message> MessageBuilder<M>` `getMessageBuilder()`
`String` `getProcessHost()`
`ProfilerEventHandler` `getProfilerEventHandler()` Returns the current ProfilerEventHandler or initializes a new one if none exists.
`PropertySet` `getPropertySet()`
`String` `getQueryTimingUnits()`
`SocketAddress` `getRemoteSocketAddress()`
`ServerSession` `getServerSession()`
`long` `getThreadId()`
`boolean` `isClosed()`
`boolean` `isSetNeededForAutoCommitMode(boolean autoCommitFlag)`
`boolean` `isSSLEstablished()`
`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.
`default <M extends Message,R extends QueryResult> R` `query(M message, ResultBuilder<R> resultBuilder)` Synchronously query database.
`default <M extends Message,R extends QueryResult> CompletableFuture<R>` `queryAsync(M message, ResultBuilder<R> resultBuilder)` Asynchronously query database.
`void` `quit()` Log-off of the MySQL server and close the socket.
`void` `removeListener(Session.SessionEventListener l)` Remove session listener.
`void` `setExceptionInterceptor(ExceptionInterceptor exceptionInterceptor)`
`boolean` `versionMeetsMinimum(int major, int minor, int subminor)` Does the version of the MySQL server we are connected to meet the given minimums?

### Method Detail

#### getPropertySet

    PropertySet getPropertySet()

#### getMessageBuilder

    <M extends Message> MessageBuilder<M> getMessageBuilder()

#### changeUser

    void changeUser(String userName,
                    String password,
                    String database)

Re-authenticates as the given user and password

Parameters:
  `userName` - DB user name
  `password` - DB user password
  `database` - database name

#### getExceptionInterceptor

    ExceptionInterceptor getExceptionInterceptor()

#### setExceptionInterceptor

    void setExceptionInterceptor(ExceptionInterceptor exceptionInterceptor)

#### quit

    void quit()

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

#### forceClose

    void forceClose()

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

#### versionMeetsMinimum

    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` - major version number
  `minor` - minor version number
  `subminor` - sub-minor version number
Returns:
  true if current server version equal or higher than provided one

#### getThreadId

    long getThreadId()

#### isSetNeededForAutoCommitMode

    boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag)

#### getLog

    Log getLog()

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

Returns:
  the Log instance to use for logging messages.

#### getProfilerEventHandler

    ProfilerEventHandler getProfilerEventHandler()

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

Returns:
  the `ProfilerEventHandler` object.

#### getHostInfo

    HostInfo getHostInfo()

#### getQueryTimingUnits

    String getQueryTimingUnits()

#### getServerSession

    ServerSession getServerSession()

#### isSSLEstablished

    boolean isSSLEstablished()

#### getRemoteSocketAddress

    SocketAddress getRemoteSocketAddress()

#### getProcessHost

    String getProcessHost()

#### addListener

    void addListener(Session.SessionEventListener l)

Add listener for this session status changes.

Parameters:
  `l` - `Session.SessionEventListener` instance.

#### removeListener

    void removeListener(Session.SessionEventListener l)

Remove session listener.

Parameters:
  `l` - `Session.SessionEventListener` instance.

#### isClosed

    boolean isClosed()

#### getIdentifierQuoteString

    String getIdentifierQuoteString()

#### getDataStoreMetadata

    DataStoreMetadata getDataStoreMetadata()

#### query

    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.

Type Parameters:
  `M` - Message type
  `R` - Row type
  `RES` - Result type
Parameters:
  `message` - query message
  `rowFilter` - row filter function
  `rowMapper` - row map function
  `collector` - result collector
Returns:
  List of rows

#### query

    default <M extends Message,R extends QueryResult> R query(M message,
                                                              ResultBuilder<R> resultBuilder)

Synchronously query database.

Type Parameters:
  `M` - Message type
  `R` - Result type
Parameters:
  `message` - query message
  `resultBuilder` - ResultBuilder instance
Returns:
  `QueryResult` object

#### queryAsync

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

Asynchronously query database.

Type Parameters:
  `M` - Message type
  `R` - Result type
Parameters:
  `message` - query message
  `resultBuilder` - ResultBuilder instance
Returns:
  CompletableFuture providing a `QueryResult` object

Copyright © 2016, 2023, Oracle and/or its affiliates.