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
`MariaSelectResultSet` `activeStreamingResult`
`protected boolean` `connected`
`protected HostAddress` `currentHost`
`protected String` `database`
`int` `dataTypeMappingFlags`
`protected boolean` `explicitClosed`
`boolean` `hasWarnings`
`protected ReentrantLock` `lock`
`protected boolean` `moreResults`
`boolean` `moreResultsTypeBinary`
`protected Options` `options`
`protected ReadPacketFetcher` `packetFetcher`
`protected PrepareStatementCache` `prepareStatementCache`
`protected FailoverProxy` `proxy`
`protected boolean` `readOnly`
`short` `serverStatus`
`protected long` `serverThreadId`
`protected Socket` `socket`
`protected UrlParser` `urlParser`
`protected PacketOutputStream` `writer`

### Constructor Summary

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

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `checkIfMaster()`
`void` `close()` Closes socket and stream readers/writers Attempts graceful shutdown.
`protected static void` `close(ReadPacketFetcher fetcher, PacketOutputStream packetOutputStream, Socket socket)`
`void` `connect()` Connect to currentHost.
`void` `connectWithoutProxy()` Connect without proxy.
`abstract void` `executeQuery(String sql)`
`MariaSelectResultSet` `getActiveStreamingResult()`
`Calendar` `getCalendar()`
`String` `getDatabase()`
`int` `getDataTypeMappingFlags()`
`String` `getHost()`
`HostAddress` `getHostAddress()`
`ReentrantLock` `getLock()`
`int` `getMajorServerVersion()`
`int` `getMinorServerVersion()`
`abstract void` `getMoreResults(ExecutionResult executionResult)`
`Options` `getOptions()`
`String` `getPassword()`
`boolean` `getPinGlobalTxToPhysicalConnection()`
`int` `getPort()`
`PrepareStatementCache` `getPrepareStatementCache()`
`FailoverProxy` `getProxy()`
`boolean` `getReadonly()`
`String` `getServerData(String code)`
`long` `getServerThreadId()`
`String` `getServerVersion()`
`UrlParser` `getUrlParser()`
`String` `getUsername()`
`boolean` `hasMoreResults()`
`boolean` `hasWarnings()` Has warnings.
`boolean` `isClosed()` Is the connection closed.
`boolean` `isConnected()` Is connected.
`boolean` `isExplicitClosed()`
`boolean` `isMasterConnection()`
`boolean` `mustBeMasterConnection()`
`boolean` `noBackslashEscapes()`
`void` `readEofPacket()` Check that next read packet is a End-of-file packet.
`void` `setActiveStreamingResult(MariaSelectResultSet activeStreamingResult)`
`void` `setHasWarnings(boolean hasWarnings)`
`void` `setHostAddress(HostAddress host)`
`void` `setHostFailedWithoutProxy()`
`void` `setMoreResults(boolean moreResults, boolean isBinary)`
`void` `setProxy(FailoverProxy proxy)`
`void` `setReadonly(boolean readOnly)`
`boolean` `shouldReconnectWithoutProxy()`
`void` `skip()` Skip packets not read that are not needed.
`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

`cancelCurrentQuery, closeExplicit, executePreparedQuery, executePreparedQueryAfterFailover, executeQueries, executeQueries, executeQueriesRewrite, executeQuery, forceReleasePrepareStatement, getAutocommit, getMaxRows, getResult, getTimeout, getTransactionIsolationLevel, inTransaction, ping, prepare, prepareStatementCache, prolog, prologProxy, releasePrepareStatement, rollback, setCatalog, setInternalMaxRows, setLocalInfileInputStream, setMaxRows, setTimeout, setTransactionIsolation`

### Field Detail

#### lock

    protected final ReentrantLock lock

#### urlParser

    protected final UrlParser urlParser

#### options

    protected final Options options

#### socket

    protected Socket socket

#### writer

    protected PacketOutputStream writer

#### readOnly

    protected boolean readOnly

#### packetFetcher

    protected ReadPacketFetcher packetFetcher

#### currentHost

    protected HostAddress currentHost

#### proxy

    protected FailoverProxy proxy

#### connected

    protected volatile boolean connected

#### explicitClosed

    protected boolean explicitClosed

#### database

    protected String database

#### serverThreadId

    protected long serverThreadId

#### prepareStatementCache

    protected PrepareStatementCache prepareStatementCache

#### moreResults

    protected boolean moreResults

#### moreResultsTypeBinary

    public boolean moreResultsTypeBinary

#### hasWarnings

    public boolean hasWarnings

#### activeStreamingResult

    public MariaSelectResultSet activeStreamingResult

#### dataTypeMappingFlags

    public int dataTypeMappingFlags

#### serverStatus

    public short serverStatus

### Constructor Detail

#### AbstractConnectProtocol

    public AbstractConnectProtocol(UrlParser urlParser,
                                   ReentrantLock lock)

Get a protocol instance.

Parameters:
  `urlParser` - connection URL infos
  `lock` - the lock for thread synchronisation

### Method Detail

#### skip

    public void skip()
              throws SQLException,
                     QueryException

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.

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

#### getMoreResults

    public abstract void getMoreResults(ExecutionResult executionResult)
                                 throws QueryException

Specified by:
  `getMoreResults` in interface `Protocol`
Throws:
  `QueryException`

#### setMoreResults

    public void setMoreResults(boolean moreResults,
                               boolean isBinary)

Specified by:
  `setMoreResults` in interface `Protocol`

#### close

    public void close()

Closes socket and stream readers/writers Attempts graceful shutdown.

Specified by:
  `close` in interface `Protocol`

#### close

    protected static void close(ReadPacketFetcher fetcher,
                                PacketOutputStream packetOutputStream,
                                Socket socket)
                         throws QueryException

Throws:
  `QueryException`

#### connect

    public void connect()
                 throws QueryException

Connect to currentHost.

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

#### isClosed

    public boolean isClosed()

Is the connection closed.

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

#### getServerData

    public String getServerData(String code)

Specified by:
  `getServerData` in interface `Protocol`

#### checkIfMaster

    public boolean checkIfMaster()
                          throws QueryException

Specified by:
  `checkIfMaster` in interface `Protocol`
Throws:
  `QueryException`

#### readEofPacket

    public void readEofPacket()
                       throws QueryException,
                              IOException

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

Throws:
  `QueryException` - 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()

Specified by:
  `isMasterConnection` in interface `Protocol`

#### 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 QueryException

Connect without proxy. (use basic failover implementation)

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

#### shouldReconnectWithoutProxy

    public boolean shouldReconnectWithoutProxy()

Specified by:
  `shouldReconnectWithoutProxy` in interface `Protocol`

#### 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`

#### getPassword

    public String getPassword()

Specified by:
  `getPassword` 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`

#### getDataTypeMappingFlags

    public int getDataTypeMappingFlags()

Specified by:
  `getDataTypeMappingFlags` in interface `Protocol`

#### isExplicitClosed

    public boolean isExplicitClosed()

Specified by:
  `isExplicitClosed` in interface `Protocol`

#### getCalendar

    public Calendar getCalendar()

Specified by:
  `getCalendar` 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 MariaSelectResultSet getActiveStreamingResult()

Specified by:
  `getActiveStreamingResult` in interface `Protocol`

#### setActiveStreamingResult

    public void setActiveStreamingResult(MariaSelectResultSet activeStreamingResult)

Specified by:
  `setActiveStreamingResult` in interface `Protocol`

#### getLock

    public ReentrantLock getLock()

Specified by:
  `getLock` in interface `Protocol`

#### hasMoreResults

    public boolean hasMoreResults()

Specified by:
  `hasMoreResults` in interface `Protocol`

#### getPrepareStatementCache

    public PrepareStatementCache getPrepareStatementCache()

#### executeQuery

    public abstract void executeQuery(String sql)
                               throws QueryException

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