Example usage for io.vertx.pgclient PgConnectOptions PgConnectOptions

List of usage examples for io.vertx.pgclient PgConnectOptions PgConnectOptions

Introduction

In this page you can find the example usage for io.vertx.pgclient PgConnectOptions PgConnectOptions.

Prototype

public PgConnectOptions() 

Source Link

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void pubsub04(Vertx vertx) {

    PgSubscriber subscriber = PgSubscriber.subscriber(vertx, new PgConnectOptions().setPort(5432)
            .setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret"));

    // Reconnect at most 10 times after 100 ms each
    subscriber.reconnectPolicy(retries -> {
        if (retries < 10) {
            return 100L;
        } else {/*from w w  w . j  a  v a  2s . c om*/
            return -1L;
        }
    });
}

From source file:examples.PgClientExamples.java

License:Apache License

public void ex10(Vertx vertx) {

    PgConnectOptions options = new PgConnectOptions().setPort(5432).setHost("the-host").setDatabase("the-db")
            .setUser("user").setPassword("secret").setSslMode(SslMode.VERIFY_CA)
            .setPemTrustOptions(new PemTrustOptions().addCertPath("/path/to/cert.pem"));

    PgConnection.connect(vertx, options, res -> {
        if (res.succeeded()) {
            // Connected with SSL
        } else {/*from w  ww . ja  v  a2s  .c  om*/
            System.out.println("Could not connect " + res.cause());
        }
    });
}