Package io.vertx.mysqlclient

## Interface MySQLConnection

- All Superinterfaces:
    `SqlClient`, `SqlConnection`

      public interface MySQLConnection
      extends SqlConnection

  An interface which represents a connection to MySQL server.

  The connection object supports all the operations defined in the `SqlConnection` interface, in addition it provides MySQL utility command support:

  - COM_PING
  - COM_CHANGE_USER
  - COM_RESET_CONNECTION
  - COM_DEBUG
  - COM_INIT_DB
  - COM_STATISTICS
  - COM_SET_OPTION

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static MySQLConnection` | `cast​(SqlConnection sqlConnection)` | Cast a `SqlConnection` to `MySQLConnection`.
    `Future<Void>` | `changeUser​(MySQLAuthOptions options)` | Send a CHANGE_USER command to change the user of the current connection, this operation will also reset connection state.
    `MySQLConnection` | `closeHandler​(Handler<Void> handler)` | Set an handler called when the connection is closed.
    `static Future<MySQLConnection>` | `connect​(Vertx vertx, MySQLConnectOptions connectOptions)` | Create a connection to MySQL server with the given `connectOptions`.
    `static Future<MySQLConnection>` | `connect​(Vertx vertx, String connectionUri)` | Like `connect(Vertx, MySQLConnectOptions)` with options built from `connectionUri`.
    `Future<Void>` | `debug()` | Send a DEBUG command to dump debug information to the server's stdout.
    `MySQLConnection` | `exceptionHandler​(Handler<Throwable> handler)` | Set an handler called with connection errors.
    `Future<String>` | `getInternalStatistics()` | Send a STATISTICS command to get a human readable string of the server internal status.
    `Future<Void>` | `ping()` | Send a PING command to check if the server is alive.
    `Future<Void>` | `resetConnection()` | Send a RESET_CONNECTION command to reset the session state.
    `Future<Void>` | `setOption​(MySQLSetOption option)` | Send a SET_OPTION command to set options for the current connection.
    `Future<Void>` | `specifySchema​(String schemaName)` | Send a INIT_DB command to change the default schema of the connection.

    - ### Methods inherited from interface io.vertx.sqlclient.SqlClient

      `close, preparedQuery, preparedQuery, query`

    - ### Methods inherited from interface io.vertx.sqlclient.SqlConnection

      `begin, databaseMetadata, isSSL, prepare, prepare, transaction`

- - ### Method Detail

    - #### connect

          static Future<MySQLConnection> connect​(Vertx vertx,
                                                 MySQLConnectOptions connectOptions)

      Create a connection to MySQL server with the given `connectOptions`.
      Parameters:
        `vertx` - the vertx instance
        `connectOptions` - the options for the connection
      Returns:
        a future notified with the connection or the failure

    - #### connect

          static Future<MySQLConnection> connect​(Vertx vertx,
                                                 String connectionUri)

      Like `connect(Vertx, MySQLConnectOptions)` with options built from `connectionUri`.

    - #### exceptionHandler

          MySQLConnection exceptionHandler​(Handler<Throwable> handler)

      Set an handler called with connection errors.
      Specified by:
        `exceptionHandler` in interface `SqlConnection`
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### closeHandler

          MySQLConnection closeHandler​(Handler<Void> handler)

      Set an handler called when the connection is closed.
      Specified by:
        `closeHandler` in interface `SqlConnection`
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### ping

          Future<Void> ping()

      Send a PING command to check if the server is alive.
      Returns:
        a future notified with the server response

    - #### specifySchema

          Future<Void> specifySchema​(String schemaName)

      Send a INIT_DB command to change the default schema of the connection.
      Parameters:
        `schemaName` - name of the schema to change to
      Returns:
        a future notified with the execution result

    - #### getInternalStatistics

          Future<String> getInternalStatistics()

      Send a STATISTICS command to get a human readable string of the server internal status.
      Returns:
        a future notified with the execution result

    - #### setOption

          Future<Void> setOption​(MySQLSetOption option)

      Send a SET_OPTION command to set options for the current connection.
      Parameters:
        `option` - the options to set
      Returns:
        a future notified with the execution result

    - #### resetConnection

          Future<Void> resetConnection()

      Send a RESET_CONNECTION command to reset the session state.
      Returns:
        a future notified with the execution result

    - #### debug

          Future<Void> debug()

      Send a DEBUG command to dump debug information to the server's stdout.
      Returns:
        a future notified with the execution result

    - #### changeUser

          Future<Void> changeUser​(MySQLAuthOptions options)

      Send a CHANGE_USER command to change the user of the current connection, this operation will also reset connection state.
      Returns:
        a future notified with the execution result

    - #### cast

          static MySQLConnection cast​(SqlConnection sqlConnection)

      Cast a `SqlConnection` to `MySQLConnection`. This is mostly useful for Vert.x generated APIs like RxJava/Mutiny.
      Parameters:
        `sqlConnection` - the connection to cast
      Returns:
        a `instance`