org.mariadb.jdbc.internal.mysql

## Class MySQLProtocol

- java.lang.Object
- - org.mariadb.jdbc.internal.mysql.MySQLProtocol

    public class MySQLProtocol
    extends Object

### Nested Class Summary

Nested Classes
`class` `MySQLProtocol.PrepareResult`

### Field Summary

Fields
`StreamingSelectResult` `activeResult`
`int` `datatypeMappingFlags`
`boolean` `hasWarnings`
`boolean` `moreResults`
`short` `serverStatus`

### Constructor Summary

Constructors
Constructor and Description
`MySQLProtocol(JDBCUrl url, String username, String password, Properties info)` Get a protocol instance

### Method Summary

Methods
`void` `cancelCurrentQuery()` cancels the current query - clones the current protocol and executes a query using the new connection thread safe
`void` `close()` Closes socket and stream readers/writers Attempts graceful shutdown.
`void` `closePreparedStatement(int statementId)`
`void` `connect()`
`boolean` `createDB()`
`QueryResult` `executeQuery(Query dQuery)`
`QueryResult` `executeQuery(Query dQuery, boolean streaming)`
`boolean` `getAutocommit()`
`String` `getDatabase()`
`String` `getHost()`
`Properties` `getInfo()`
`int` `getMajorServerVersion()`
`int` `getMinorServerVersion()`
`QueryResult` `getMoreResults(boolean streaming)`
`String` `getPassword()`
`int` `getPort()`
`boolean` `getReadonly()`
`QueryResult` `getResult(Query dQuery, boolean streaming)`
`String` `getServerVariable(String variable)`
`String` `getServerVersion()`
`String` `getUsername()`
`boolean` `hasMoreResults()`
`boolean` `hasUnreadData()`
`static String` `hexdump(byte[] buffer, int offset)`
`static String` `hexdump(ByteBuffer bb, int offset)`
`boolean` `inTransaction()`
`boolean` `isClosed()`
`boolean` `isMasterConnection()`
`boolean` `ping()`
`MySQLProtocol.PrepareResult` `prepare(String sql)`
`void` `reconnectToMaster()`
`void` `selectDB(String database)`
`void` `setHostFailed()`
`void` `setLocalInfileInputStream(InputStream inputStream)`
`void` `setMaxRows(int max)`
`void` `setReadonly(boolean readOnly)`
`boolean` `shouldReconnect()`
`boolean` `shouldTryFailback()` Check if fail back to master connection is desired,
`boolean` `versionGreaterOrEqual(int major, int minor, int patch)`

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

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

### Field Detail

#### moreResults

    public boolean moreResults

#### hasWarnings

    public boolean hasWarnings

#### activeResult

    public StreamingSelectResult activeResult

#### datatypeMappingFlags

    public int datatypeMappingFlags

#### serverStatus

    public short serverStatus

### Constructor Detail

#### MySQLProtocol

    public MySQLProtocol(JDBCUrl url,
                 String username,
                 String password,
                 Properties info)
                  throws QueryException

Get a protocol instance

Parameters:
  `url` - connection URL
  `username` - the username
  `password` - the password
  `info` -
Throws:
  `QueryException` - if there is a problem reading / sending the packets

### Method Detail

#### prepare

    public MySQLProtocol.PrepareResult prepare(String sql)
                                        throws QueryException

Throws:
  `QueryException`

#### closePreparedStatement

    public void closePreparedStatement(int statementId)
                                throws QueryException

Throws:
  `QueryException`

#### setHostFailed

    public void setHostFailed()

#### shouldReconnect

    public boolean shouldReconnect()

#### getAutocommit

    public boolean getAutocommit()

#### reconnectToMaster

    public void reconnectToMaster()
                           throws IOException,
                                  QueryException

Throws:
  `IOException`
  `QueryException`

#### connect

    public void connect()
                 throws QueryException

Throws:
  `QueryException`

#### isMasterConnection

    public boolean isMasterConnection()

#### shouldTryFailback

    public boolean shouldTryFailback()

Check if fail back to master connection is desired,

Returns:

#### inTransaction

    public boolean inTransaction()

#### getInfo

    public Properties getInfo()

#### hasMoreResults

    public boolean hasMoreResults()

#### close

    public void close()

Closes socket and stream readers/writers Attempts graceful shutdown.

Throws:
  `QueryException` - if the socket or readers/writes cannot be closed

#### isClosed

    public boolean isClosed()

Returns:
  true if the connection is closed

#### selectDB

    public void selectDB(String database)
                  throws QueryException

Throws:
  `QueryException`

#### getServerVersion

    public String getServerVersion()

#### setReadonly

    public void setReadonly(boolean readOnly)

#### getReadonly

    public boolean getReadonly()

#### getHost

    public String getHost()

#### getPort

    public int getPort()

#### getDatabase

    public String getDatabase()

#### getUsername

    public String getUsername()

#### getPassword

    public String getPassword()

#### ping

    public boolean ping()
                 throws QueryException

Throws:
  `QueryException`

#### executeQuery

    public QueryResult executeQuery(Query dQuery)
                             throws QueryException

Throws:
  `QueryException`

#### getResult

    public QueryResult getResult(Query dQuery,
                        boolean streaming)
                          throws QueryException

Throws:
  `QueryException`

#### executeQuery

    public QueryResult executeQuery(Query dQuery,
                           boolean streaming)
                             throws QueryException

Throws:
  `QueryException`

#### getServerVariable

    public String getServerVariable(String variable)
                             throws QueryException

Throws:
  `QueryException`

#### cancelCurrentQuery

    public void cancelCurrentQuery()
                            throws QueryException,
                                   IOException

cancels the current query - clones the current protocol and executes a query using the new connection

thread safe

Throws:
  `QueryException`
  `IOException`

#### createDB

    public boolean createDB()

#### getMoreResults

    public QueryResult getMoreResults(boolean streaming)
                               throws QueryException

Throws:
  `QueryException`

#### hexdump

    public static String hexdump(byte[] buffer,
                 int offset)

#### hexdump

    public static String hexdump(ByteBuffer bb,
                 int offset)

#### hasUnreadData

    public boolean hasUnreadData()

#### setMaxRows

    public void setMaxRows(int max)
                    throws QueryException

Throws:
  `QueryException`

#### getMajorServerVersion

    public int getMajorServerVersion()

#### getMinorServerVersion

    public int getMinorServerVersion()

#### versionGreaterOrEqual

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

#### setLocalInfileInputStream

    public void setLocalInfileInputStream(InputStream inputStream)