org.mariadb.jdbc.internal.protocol

## Class AbstractConnectProtocol

- java.lang.Object
- - org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol

All Implemented Interfaces:
  Protocol

Direct Known Subclasses:
  AbstractQueryProtocol

    public abstract class AbstractConnectProtocol
    extends Object
    implements Protocol

### Field Summary

Fields
`Results` `activeStreamingResult`
`protected int` `autoIncrementIncrement`
`protected boolean` `connected`
`protected String` `database`
`protected boolean` `eofDeprecated`
`protected boolean` `explicitClosed`
`boolean` `hasWarnings`
`protected ReentrantLock` `lock`
`protected Options` `options`
`protected FailoverProxy` `proxy`
`protected PacketInputStream` `reader`
`protected boolean` `readOnly`
`protected long` `serverCapabilities`
`protected ServerPrepareStatementCache` `serverPrepareStatementCache`
`short` `serverStatus`
`protected long` `serverThreadId`
`protected Socket` `socket`
`protected int` `socketTimeout`
`protected UrlParser` `urlParser`
`protected PacketOutputStream` `writer`

### Constructor Summary

Constructors
Constructor and Description
`AbstractConnectProtocol(UrlParser urlParser, GlobalStateInfo globalInfo, ReentrantLock lock)` Get a protocol instance.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `abort()` Force closes socket and stream readers/writers.
`void` `changeSocketSoTimeout(int setSoTimeout)`
`void` `changeSocketTcpNoDelay(boolean setTcpNoDelay)` Change Socket TcpNoDelay option.
`boolean` `checkIfMaster()` Check that current connection is a master connection (not read-only).
`void` `close()` Closes socket and stream readers/writers Attempts graceful shutdown.
`void` `connect()` Connect to currentHost.
`void` `connectWithoutProxy()` Connect without proxy.
`void` `destroySocket()` Closing socket in case of Connection error after socket creation.
`abstract void` `executeQuery(String sql)`
`Results` `getActiveStreamingResult()`
`String` `getDatabase()`
`String` `getHost()`
`HostAddress` `getHostAddress()`
`ReentrantLock` `getLock()`
`int` `getMajorServerVersion()`
`int` `getMinorServerVersion()`
`Options` `getOptions()`
`boolean` `getPinGlobalTxToPhysicalConnection()`
`int` `getPort()`
`FailoverProxy` `getProxy()`
`PacketInputStream` `getReader()`
`boolean` `getReadonly()`
`long` `getServerThreadId()`
`String` `getServerVersion()`
`Socket` `getSocket()`
`TimeZone` `getTimeZone()`
`String` `getTraces()` Get a String containing readable information about last 10 send/received packets.
`UrlParser` `getUrlParser()`
`String` `getUsername()`
`PacketOutputStream` `getWriter()`
`boolean` `hasMoreResults()`
`boolean` `hasWarnings()` Has warnings.
`boolean` `isClosed()` Is the connection closed.
`boolean` `isConnected()` Is connected.
`boolean` `isEofDeprecated()`
`boolean` `isExplicitClosed()`
`boolean` `isMasterConnection()` Indicate if current protocol is a master protocol.
`boolean` `isServerMariaDb()`
`boolean` `mustBeMasterConnection()`
`boolean` `noBackslashEscapes()`
`ServerPrepareStatementCache` `prepareStatementCache()`
`void` `readEofPacket()` Check that next read packet is a End-of-file packet.
`void` `readPipelineCheckMaster()`
`void` `removeActiveStreamingResult()` Remove exception result and since totally fetched, set fetch size to 0.
`void` `removeHasMoreResults()` Remove flag has more results.
`boolean` `sessionStateAware()`
`void` `setActiveStreamingResult(Results activeStreamingResult)`
`void` `setHasWarnings(boolean hasWarnings)`
`void` `setHostAddress(HostAddress host)`
`void` `setHostFailedWithoutProxy()`
`void` `setProxy(FailoverProxy proxy)`
`void` `setReadonly(boolean readOnly)`
`void` `setServerStatus(short serverStatus)`
`boolean` `shouldReconnectWithoutProxy()` Indicate for Old reconnection if can reconnect without throwing exception.
`void` `skip()` Skip packets not read that are not needed.
`void` `skipEofPacket()` Check that next read packet is a End-of-file packet.
`boolean` `versionGreaterOrEqual(int major, int minor, int patch)` Utility method to check if database version is greater than parameters.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.mariadb.jdbc.internal.protocol.Protocol

`addPrepareInCache, cancelCurrentQuery, closeExplicit, executeBatchClient, executeBatchServer, executeBatchStmt, executePreparedQuery, executeQuery, executeQuery, executeQuery, executeQuery, forceReleasePrepareStatement, forceReleaseWaitingPrepareStatement, getAutocommit, getAutoIncrementIncrement, getCatalog, getMaxRows, getResult, getTimeout, getTransactionIsolationLevel, handleIoException, interrupt, inTransaction, isInterrupted, isValid, ping, prepare, prolog, prologProxy, releasePrepareStatement, reset, resetDatabase, resetStateAfterFailover, rollback, setActiveFutureTask, setCatalog, setLocalInfileInputStream, setMaxRows, setTimeout, setTransactionIsolation, stopIfInterrupted`

### Field Detail

#### lock

    protected final ReentrantLock lock

#### urlParser

    protected final UrlParser urlParser

#### options

    protected final Options options

#### hasWarnings

    public boolean hasWarnings

#### activeStreamingResult

    public Results activeStreamingResult

#### serverStatus

    public short serverStatus

#### autoIncrementIncrement

    protected int autoIncrementIncrement

#### socket

    protected Socket socket

#### writer

    protected PacketOutputStream writer

#### readOnly

    protected boolean readOnly

#### reader

    protected PacketInputStream reader

#### proxy

    protected FailoverProxy proxy

#### connected

    protected volatile boolean connected

#### explicitClosed

    protected boolean explicitClosed

#### database

    protected String database

#### serverThreadId

    protected long serverThreadId

#### serverPrepareStatementCache

    protected ServerPrepareStatementCache serverPrepareStatementCache

#### eofDeprecated

    protected boolean eofDeprecated

#### serverCapabilities

    protected long serverCapabilities

#### socketTimeout

    protected int socketTimeout

### Constructor Detail

#### AbstractConnectProtocol

    public AbstractConnectProtocol(UrlParser urlParser,
                                   GlobalStateInfo globalInfo,
                                   ReentrantLock lock)

Get a protocol instance.

Parameters:
  `urlParser` - connection URL information
  `globalInfo` - server global variables information
  `lock` - the lock for thread synchronisation

### Method Detail

#### close

    public void close()

Closes socket and stream readers/writers Attempts graceful shutdown.

Specified by:
  `close` in interface `Protocol`

#### abort

    public void abort()

Force closes socket and stream readers/writers.

Specified by:
  `abort` in interface `Protocol`

#### skip

    public void skip()
              throws SQLException

Skip packets not read that are not needed. Packets are read according to needs. If some data have not been read before next execution, skip it. Lock must be set before using this method

Specified by:
  `skip` in interface `Protocol`
Throws:
  `SQLException` - exception

#### setServerStatus

    public void setServerStatus(short serverStatus)

Specified by:
  `setServerStatus` in interface `Protocol`

#### removeHasMoreResults

    public void removeHasMoreResults()

Remove flag has more results.

Specified by:
  `removeHasMoreResults` in interface `Protocol`

#### connect

    public void connect()
                 throws SQLException

Connect to currentHost.

Specified by:
  `connect` in interface `Protocol`
Throws:
  `SQLException` - exception

#### destroySocket

    public void destroySocket()

Closing socket in case of Connection error after socket creation.

#### isClosed

    public boolean isClosed()

Is the connection closed.

Specified by:
  `isClosed` in interface `Protocol`
Returns:
  true if the connection is closed

#### checkIfMaster

    public boolean checkIfMaster()
                          throws SQLException

Check that current connection is a master connection (not read-only).

Specified by:
  `checkIfMaster` in interface `Protocol`
Returns:
  true if master
Throws:
  `SQLException` - if requesting infos for server fail.

#### readEofPacket

    public void readEofPacket()
                       throws SQLException,
                              IOException

Check that next read packet is a End-of-file packet.

Specified by:
  `readEofPacket` in interface `Protocol`
Throws:
  `SQLException` - if not a End-of-file packet
  `IOException` - if connection error occur

#### skipEofPacket

    public void skipEofPacket()
                       throws SQLException,
                              IOException

Check that next read packet is a End-of-file packet.

Specified by:
  `skipEofPacket` in interface `Protocol`
Throws:
  `SQLException` - if not a End-of-file packet
  `IOException` - if connection error occur

#### setHostFailedWithoutProxy

    public void setHostFailedWithoutProxy()

Specified by:
  `setHostFailedWithoutProxy` in interface `Protocol`

#### getUrlParser

    public UrlParser getUrlParser()

Specified by:
  `getUrlParser` in interface `Protocol`

#### isMasterConnection

    public boolean isMasterConnection()

Indicate if current protocol is a master protocol.

Specified by:
  `isMasterConnection` in interface `Protocol`
Returns:
  is master flag

#### readPipelineCheckMaster

    public void readPipelineCheckMaster()
                                 throws SQLException

Throws:
  `SQLException`

#### mustBeMasterConnection

    public boolean mustBeMasterConnection()

Specified by:
  `mustBeMasterConnection` in interface `Protocol`

#### noBackslashEscapes

    public boolean noBackslashEscapes()

Specified by:
  `noBackslashEscapes` in interface `Protocol`

#### connectWithoutProxy

    public void connectWithoutProxy()
                             throws SQLException

Connect without proxy. (use basic failover implementation)

Specified by:
  `connectWithoutProxy` in interface `Protocol`
Throws:
  `SQLException` - exception

#### shouldReconnectWithoutProxy

    public boolean shouldReconnectWithoutProxy()

Indicate for Old reconnection if can reconnect without throwing exception.

Specified by:
  `shouldReconnectWithoutProxy` in interface `Protocol`
Returns:
  true if can reconnect without issue

#### getServerVersion

    public String getServerVersion()

Specified by:
  `getServerVersion` in interface `Protocol`

#### getReadonly

    public boolean getReadonly()

Specified by:
  `getReadonly` in interface `Protocol`

#### setReadonly

    public void setReadonly(boolean readOnly)

Specified by:
  `setReadonly` in interface `Protocol`

#### getHostAddress

    public HostAddress getHostAddress()

Specified by:
  `getHostAddress` in interface `Protocol`

#### setHostAddress

    public void setHostAddress(HostAddress host)

Specified by:
  `setHostAddress` in interface `Protocol`

#### getHost

    public String getHost()

Specified by:
  `getHost` in interface `Protocol`

#### getProxy

    public FailoverProxy getProxy()

Specified by:
  `getProxy` in interface `Protocol`

#### setProxy

    public void setProxy(FailoverProxy proxy)

Specified by:
  `setProxy` in interface `Protocol`

#### getPort

    public int getPort()

Specified by:
  `getPort` in interface `Protocol`

#### getDatabase

    public String getDatabase()

Specified by:
  `getDatabase` in interface `Protocol`

#### getUsername

    public String getUsername()

Specified by:
  `getUsername` in interface `Protocol`

#### getMajorServerVersion

    public int getMajorServerVersion()

Specified by:
  `getMajorServerVersion` in interface `Protocol`

#### getMinorServerVersion

    public int getMinorServerVersion()

Specified by:
  `getMinorServerVersion` in interface `Protocol`

#### versionGreaterOrEqual

    public boolean versionGreaterOrEqual(int major,
                                         int minor,
                                         int patch)

Utility method to check if database version is greater than parameters.

Specified by:
  `versionGreaterOrEqual` in interface `Protocol`
Parameters:
  `major` - major version
  `minor` - minor version
  `patch` - patch version
Returns:
  true if version is greater than parameters

#### getPinGlobalTxToPhysicalConnection

    public boolean getPinGlobalTxToPhysicalConnection()

Specified by:
  `getPinGlobalTxToPhysicalConnection` in interface `Protocol`

#### hasWarnings

    public boolean hasWarnings()

Has warnings.

Specified by:
  `hasWarnings` in interface `Protocol`
Returns:
  true if as warnings.

#### isConnected

    public boolean isConnected()

Is connected.

Specified by:
  `isConnected` in interface `Protocol`
Returns:
  true if connected

#### getServerThreadId

    public long getServerThreadId()

Specified by:
  `getServerThreadId` in interface `Protocol`

#### getSocket

    public Socket getSocket()

Specified by:
  `getSocket` in interface `Protocol`

#### isExplicitClosed

    public boolean isExplicitClosed()

Specified by:
  `isExplicitClosed` in interface `Protocol`

#### getTimeZone

    public TimeZone getTimeZone()

Specified by:
  `getTimeZone` in interface `Protocol`

#### getOptions

    public Options getOptions()

Specified by:
  `getOptions` in interface `Protocol`

#### setHasWarnings

    public void setHasWarnings(boolean hasWarnings)

Specified by:
  `setHasWarnings` in interface `Protocol`

#### getActiveStreamingResult

    public Results getActiveStreamingResult()

Specified by:
  `getActiveStreamingResult` in interface `Protocol`

#### setActiveStreamingResult

    public void setActiveStreamingResult(Results activeStreamingResult)

Specified by:
  `setActiveStreamingResult` in interface `Protocol`

#### removeActiveStreamingResult

    public void removeActiveStreamingResult()

Remove exception result and since totally fetched, set fetch size to 0.

Specified by:
  `removeActiveStreamingResult` in interface `Protocol`

#### getLock

    public ReentrantLock getLock()

Specified by:
  `getLock` in interface `Protocol`

#### hasMoreResults

    public boolean hasMoreResults()

Specified by:
  `hasMoreResults` in interface `Protocol`

#### prepareStatementCache

    public ServerPrepareStatementCache prepareStatementCache()

Specified by:
  `prepareStatementCache` in interface `Protocol`

#### executeQuery

    public abstract void executeQuery(String sql)
                               throws SQLException

Specified by:
  `executeQuery` in interface `Protocol`
Throws:
  `SQLException`

#### changeSocketTcpNoDelay

    public void changeSocketTcpNoDelay(boolean setTcpNoDelay)

Change Socket TcpNoDelay option.

Specified by:
  `changeSocketTcpNoDelay` in interface `Protocol`
Parameters:
  `setTcpNoDelay` - value to set.

#### changeSocketSoTimeout

    public void changeSocketSoTimeout(int setSoTimeout)
                               throws SocketException

Specified by:
  `changeSocketSoTimeout` in interface `Protocol`
Throws:
  `SocketException`

#### isServerMariaDb

    public boolean isServerMariaDb()

Specified by:
  `isServerMariaDb` in interface `Protocol`

#### getReader

    public PacketInputStream getReader()

Specified by:
  `getReader` in interface `Protocol`

#### getWriter

    public PacketOutputStream getWriter()

Specified by:
  `getWriter` in interface `Protocol`

#### isEofDeprecated

    public boolean isEofDeprecated()

Specified by:
  `isEofDeprecated` in interface `Protocol`

#### sessionStateAware

    public boolean sessionStateAware()

Specified by:
  `sessionStateAware` in interface `Protocol`

#### getTraces

    public String getTraces()

Get a String containing readable information about last 10 send/received packets.

Specified by:
  `getTraces` in interface `Protocol`
Returns:
  String value