Example usage for io.vertx.mysqlclient MySQLConnection changeUser

List of usage examples for io.vertx.mysqlclient MySQLConnection changeUser

Introduction

In this page you can find the example usage for io.vertx.mysqlclient MySQLConnection changeUser.

Prototype

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

Source Link

Document

Send a CHANGE_USER command to change the user of the current connection, this operation will also reset connection state.

Usage

From source file:examples.MySQLClientExamples.java

public void changeUserExample(MySQLConnection connection) {
    MySQLAuthOptions authenticationOptions = new MySQLAuthOptions().setUser("newuser")
            .setPassword("newpassword").setDatabase("newdatabase");
    connection.changeUser(authenticationOptions, ar -> {
        if (ar.succeeded()) {
            System.out.println("User of current connection has been changed.");
        } else {//w w  w  .j ava 2 s .c o  m
            System.out.println("Failure: " + ar.cause().getMessage());
        }
    });
}