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
`StreamingSelectResult` `activeResult`
`protected boolean` `connected`
`protected HostAddress` `currentHost`
`protected String` `database`
`int` `dataTypeMappingFlags`
`protected boolean` `explicitClosed`
`boolean` `hasWarnings`
`protected ReentrantLock` `lock`
`boolean` `moreResults`
`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 AbstractQueryResult` `executeQuery(Query query)`
`Calendar` `getCalendar()`
`String` `getDatabase()`
`int` `getDataTypeMappingFlags()`
`String` `getHost()`
`HostAddress` `getHostAddress()`
`int` `getMajorServerVersion()`
`int` `getMinorServerVersion()`
`abstract AbstractQueryResult` `getMoreResults(boolean streaming)`
`Options` `getOptions()`
`String` `getPassword()`
`boolean` `getPinGlobalTxToPhysicalConnection()`
`int` `getPort()`
`FailoverProxy` `getProxy()`
`boolean` `getReadonly()`
`String` `getServerData(String code)`
`long` `getServerThreadId()`
`String` `getServerVersion()`
`UrlParser` `getUrlParser()`
`String` `getUsername()`
`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` `setHostAddress(HostAddress host)`
`void` `setHostFailedWithoutProxy()`
`void` `setProxy(FailoverProxy proxy)`
`void` `setReadonly(boolean readOnly)`
`boolean` `shouldReconnectWithoutProxy()`
`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, closeIfActiveResult, closePreparedStatement, executePreparedQuery, executePreparedQueryAfterFailover, executeQuery, executeQuery, getAutocommit, getMaxRows, getResult, getTimeout, getTransactionIsolationLevel, hasMoreResults, hasUnreadData, inTransaction, ping, prepare, prepareStatementCache, releasePrepareStatement, rollback, setCatalog, setInternalMaxRows, setLocalInfileInputStream, setMaxRows, setTimeout, setTransactionIsolation`

### Field Detail

#### lock

    protected final ReentrantLock lock

#### urlParser

    protected final UrlParser urlParser

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

    public boolean moreResults

#### hasWarnings

    public boolean hasWarnings

#### activeResult

    public StreamingSelectResult activeResult

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

#### getMoreResults

    public abstract AbstractQueryResult getMoreResults(boolean streaming)
                                                throws QueryException

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

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

#### executeQuery

    public abstract AbstractQueryResult executeQuery(Query query)
                                              throws QueryException

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