Package com.mysql.cj
Class MysqlxSession
java.lang.Object
com.mysql.cj.CoreSession
com.mysql.cj.MysqlxSession
- All Implemented Interfaces:
Session
public class MysqlxSession extends CoreSession
-
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 MysqlxSession(HostInfo hostInfo, PropertySet propSet)
MysqlxSession(XProtocol prot)
-
Method Summary
Modifier and Type Method Description boolean
failedPreparingStatement(int preparedStatementId, XProtocolError e)
Propagate to the underlying protocol instance that preparing a statement on the connected server failed.void
freePreparedStatementId(int preparedStatementId)
Free a prepared statement id so that it can be reused.int
getNewPreparedStatementId(PreparableStatement<?> preparableStatement)
Return an id to be used as a client-managed prepared statement id.int
getPort()
java.lang.String
getProcessHost()
XProtocol
getProtocol()
boolean
isClosed()
<M extends Message, R extends QueryResult>
Rquery(M message, ResultBuilder<R> resultBuilder)
Synchronously query database.<M extends Message, R, RES>
RESquery(M message, java.util.function.Predicate<Row> rowFilter, java.util.function.Function<Row,R> rowMapper, java.util.stream.Collector<R,?,RES> collector)
Synchronously query database with applying rows filtering and mapping.<M extends Message, R extends QueryResult>
java.util.concurrent.CompletableFuture<R>queryAsync(M message, ResultBuilder<R> resultBuilder)
Asynchronously query database.void
quit()
Log-off of the MySQL server and close the socket.boolean
readyForPreparingStatements()
Check if enough statements were executed in the underlying MySQL server so that another prepare statement attempt should be done.boolean
supportsPreparedStatements()
Check if current session is using a MySQL server that supports prepared statements.Methods inherited from class com.mysql.cj.CoreSession
addListener, changeUser, forceClose, getDataStoreMetadata, getExceptionInterceptor, getHostInfo, getIdentifierQuoteString, getLog, getMessageBuilder, getProfilerEventHandler, getPropertySet, getQueryTimingUnits, getRemoteSocketAddress, getServerSession, getThreadId, isSetNeededForAutoCommitMode, isSSLEstablished, removeListener, setExceptionInterceptor, versionMeetsMinimum
-
Constructor Details
-
Method Details
-
getProcessHost
public java.lang.String getProcessHost() -
getPort
public int getPort() -
getProtocol
-
quit
public void quit()Description copied from interface:Session
Log-off of the MySQL server and close the socket.- Specified by:
quit
in interfaceSession
- Overrides:
quit
in classCoreSession
-
isClosed
public boolean isClosed() -
supportsPreparedStatements
public boolean supportsPreparedStatements()Check if current session is using a MySQL server that supports prepared statements.- Returns:
true
if the MySQL server in use supports prepared statements
-
readyForPreparingStatements
public boolean readyForPreparingStatements()Check if enough statements were executed in the underlying MySQL server so that another prepare statement attempt should be done.- Returns:
true
if enough executions have been done since last time a prepared statement failed to be prepared
-
getNewPreparedStatementId
Return an id to be used as a client-managed prepared statement id.- Parameters:
preparableStatement
-PreparableStatement
- Returns:
- a new identifier to be used as prepared statement id
-
freePreparedStatementId
public void freePreparedStatementId(int preparedStatementId)Free a prepared statement id so that it can be reused.- Parameters:
preparedStatementId
- the prepared statement id to release
-
failedPreparingStatement
Propagate to the underlying protocol instance that preparing a statement on the connected server failed.- Parameters:
preparedStatementId
- the id of the prepared statement that failed to be preparede
-XProtocolError
- Returns:
true
if the exception was properly handled
-
query
public <M extends Message, R, RES> RES query(M message, java.util.function.Predicate<Row> rowFilter, java.util.function.Function<Row,R> rowMapper, java.util.stream.Collector<R,?,RES> collector)Description copied from interface:Session
Synchronously query database with applying rows filtering and mapping.- Type Parameters:
M
- Message typeR
- Row typeRES
- Result type- Parameters:
message
- query messagerowFilter
- row filter functionrowMapper
- row map functioncollector
- result collector- Returns:
- List of rows
-
query
public <M extends Message, R extends QueryResult> R query(M message, ResultBuilder<R> resultBuilder)Description copied from interface:Session
Synchronously query database.- Type Parameters:
M
- Message typeR
- Result type- Parameters:
message
- query messageresultBuilder
- ResultBuilder instance- Returns:
QueryResult
object
-
queryAsync
public <M extends Message, R extends QueryResult> java.util.concurrent.CompletableFuture<R> queryAsync(M message, ResultBuilder<R> resultBuilder)Description copied from interface:Session
Asynchronously query database.- Type Parameters:
M
- Message typeR
- Result type- Parameters:
message
- query messageresultBuilder
- ResultBuilder instance- Returns:
- CompletableFuture providing a
QueryResult
object
-