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 Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static MySQLConnection` | `cast(SqlConnection sqlConnection)` Cast a `SqlConnection` to `MySQLConnection`.
    `Future<Void>` | `changeUser(MySQLAuthOptions options)` Like `changeUser(MySQLAuthOptions, Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `changeUser(MySQLAuthOptions options, Handler<AsyncResult<Void>> handler)` 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)` Like `connect(Vertx, MySQLConnectOptions, Handler)` but returns a `Future` of the asynchronous result
    `static void` | `connect(Vertx vertx, MySQLConnectOptions connectOptions, Handler<AsyncResult<MySQLConnection>> handler)` Create a connection to MySQL server with the given `connectOptions`.
    `static Future<MySQLConnection>` | `connect(Vertx vertx, String connectionUri)` Like `connect(Vertx, String, Handler)` but returns a `Future` of the asynchronous result
    `static void` | `connect(Vertx vertx, String connectionUri, Handler<AsyncResult<MySQLConnection>> handler)` Like `connect(Vertx, MySQLConnectOptions, Handler)` with options built from `connectionUri`.
    `Future<Void>` | `debug()` Like `debug(Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `debug(Handler<AsyncResult<Void>> handler)` 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()` Like `getInternalStatistics(Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `getInternalStatistics(Handler<AsyncResult<String>> handler)` Send a STATISTICS command to get a human readable string of the server internal status.
    `Future<Void>` | `ping()` Like `ping(Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `ping(Handler<AsyncResult<Void>> handler)` Send a PING command to check if the server is alive.
    `MySQLConnection` | `prepare(String sql, Handler<AsyncResult<PreparedStatement>> handler)` Create a prepared statement using the given `sql` string.
    `Future<Void>` | `resetConnection()` Like `resetConnection(Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `resetConnection(Handler<AsyncResult<Void>> handler)` Send a RESET_CONNECTION command to reset the session state.
    `Future<Void>` | `setOption(MySQLSetOption option)` Like `setOption(MySQLSetOption, Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `setOption(MySQLSetOption option, Handler<AsyncResult<Void>> handler)` Send a SET_OPTION command to set options for the current connection.
    `Future<Void>` | `specifySchema(String schemaName)` Like `specifySchema(String, Handler)` but returns a `Future` of the asynchronous result
    `MySQLConnection` | `specifySchema(String schemaName, Handler<AsyncResult<Void>> handler)` Send a INIT_DB command to change the default schema of the connection.

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

      `begin, begin, close, databaseMetadata, isSSL, prepare`

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

      `close, preparedQuery, query`

- - ### Method Detail

    - #### connect

          static void connect(Vertx vertx,
                              MySQLConnectOptions connectOptions,
                              Handler<AsyncResult<MySQLConnection>> handler)

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

    - #### connect

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

      Like `connect(Vertx, MySQLConnectOptions, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          static void connect(Vertx vertx,
                              String connectionUri,
                              Handler<AsyncResult<MySQLConnection>> handler)

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

    - #### connect

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

      Like `connect(Vertx, String, Handler)` but returns a `Future` of the asynchronous result

    - #### prepare

          MySQLConnection prepare(String sql,
                                  Handler<AsyncResult<PreparedStatement>> handler)

      Create a prepared statement using the given `sql` string.
      Specified by:
        `prepare` in interface `SqlConnection`
      Parameters:
        `sql` - the sql
        `handler` - the handler notified with the prepared query asynchronously

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

          MySQLConnection ping(Handler<AsyncResult<Void>> handler)

      Send a PING command to check if the server is alive.
      Parameters:
        `handler` - the handler notified when the server responses to client
      Returns:
        a reference to this, so the API can be used fluently

    - #### ping

          Future<Void> ping()

      Like `ping(Handler)` but returns a `Future` of the asynchronous result

    - #### specifySchema

          MySQLConnection specifySchema(String schemaName,
                                        Handler<AsyncResult<Void>> handler)

      Send a INIT_DB command to change the default schema of the connection.
      Parameters:
        `schemaName` - name of the schema to change to
        `handler` - the handler notified with the execution result
      Returns:
        a reference to this, so the API can be used fluently

    - #### specifySchema

          Future<Void> specifySchema(String schemaName)

      Like `specifySchema(String, Handler)` but returns a `Future` of the asynchronous result

    - #### getInternalStatistics

          MySQLConnection getInternalStatistics(Handler<AsyncResult<String>> handler)

      Send a STATISTICS command to get a human readable string of the server internal status.
      Parameters:
        `handler` - the handler notified with the execution result
      Returns:
        a reference to this, so the API can be used fluently

    - #### getInternalStatistics

          Future<String> getInternalStatistics()

      Like `getInternalStatistics(Handler)` but returns a `Future` of the asynchronous result

    - #### setOption

          MySQLConnection setOption(MySQLSetOption option,
                                    Handler<AsyncResult<Void>> handler)

      Send a SET_OPTION command to set options for the current connection.
      Parameters:
        `option` - the options to set
        `handler` - the handler notified with the execution result
      Returns:
        a reference to this, so the API can be used fluently

    - #### setOption

          Future<Void> setOption(MySQLSetOption option)

      Like `setOption(MySQLSetOption, Handler)` but returns a `Future` of the asynchronous result

    - #### resetConnection

          MySQLConnection resetConnection(Handler<AsyncResult<Void>> handler)

      Send a RESET_CONNECTION command to reset the session state.
      Parameters:
        `handler` - the handler notified with the execution result
      Returns:
        a reference to this, so the API can be used fluently

    - #### resetConnection

          Future<Void> resetConnection()

      Like `resetConnection(Handler)` but returns a `Future` of the asynchronous result

    - #### debug

          MySQLConnection debug(Handler<AsyncResult<Void>> handler)

      Send a DEBUG command to dump debug information to the server's stdout.
      Parameters:
        `handler` - the handler notified with the execution result
      Returns:
        a reference to this, so the API can be used fluently

    - #### debug

          Future<Void> debug()

      Like `debug(Handler)` but returns a `Future` of the asynchronous result

    - #### changeUser

          MySQLConnection changeUser(MySQLAuthOptions options,
                                     Handler<AsyncResult<Void>> handler)

      Send a CHANGE_USER command to change the user of the current connection, this operation will also reset connection state.
      Parameters:
        `options` - authentication options
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### changeUser

          Future<Void> changeUser(MySQLAuthOptions options)

      Like `changeUser(MySQLAuthOptions, Handler)` but returns a `Future` of the asynchronous 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`

Copyright © 2021 Eclipse. All rights reserved.