List of usage examples for io.vertx.mysqlclient MySQLConnection connect
static void connect(Vertx vertx, String connectionUri, Handler<AsyncResult<MySQLConnection>> handler)
From source file:examples.MySQLClientExamples.java
public void configureFromUri(Vertx vertx) { // Connection URI String connectionUri = "mysql://dbuser:secretpassword@database.server.com:3211/mydb"; // Create the pool from the connection URI MySQLPool pool = MySQLPool.pool(connectionUri); // Create the connection from the connection URI MySQLConnection.connect(vertx, connectionUri, res -> { // Handling your connection });/*from w ww. j a v a2 s .c o m*/ }
From source file:examples.MySQLClientExamples.java
public void tlsExample(Vertx vertx) { MySQLConnectOptions options = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret").setSslMode(SslMode.VERIFY_CA) .setPemTrustOptions(new PemTrustOptions().addCertPath("/path/to/cert.pem")); MySQLConnection.connect(vertx, options, res -> { if (res.succeeded()) { // Connected with SSL } else {/*w ww. j ava 2 s .c om*/ System.out.println("Could not connect " + res.cause()); } }); }