Search in sources :

Example 11 with MSSQLConnectOptions

use of io.vertx.mssqlclient.MSSQLConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLConnectionAutoRetryTest method initialConnector.

@Override
protected void initialConnector(int proxyPort) {
    SqlConnectOptions proxyOptions = new MSSQLConnectOptions(options);
    proxyOptions.setPort(proxyPort);
    proxyOptions.setHost("localhost");
    connectionConnector = ClientConfig.CONNECT.connect(vertx, proxyOptions);
    poolConnector = ClientConfig.POOLED.connect(vertx, proxyOptions);
}
Also used : SqlConnectOptions(io.vertx.sqlclient.SqlConnectOptions) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions)

Example 12 with MSSQLConnectOptions

use of io.vertx.mssqlclient.MSSQLConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLClientExamples method gettingStarted.

public void gettingStarted() {
    // Connect options
    MSSQLConnectOptions connectOptions = new MSSQLConnectOptions().setPort(1433).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
    // Pool options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
    // Create the client pool
    MSSQLPool client = MSSQLPool.pool(connectOptions, poolOptions);
    // A simple query
    client.query("SELECT * FROM users WHERE id='julien'").execute(ar -> {
        if (ar.succeeded()) {
            RowSet result = ar.result();
            System.out.println("Got " + result.size() + " rows ");
        } else {
            System.out.println("Failure: " + ar.cause().getMessage());
        }
        // Now close the pool
        client.close();
    });
}
Also used : MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Example 13 with MSSQLConnectOptions

use of io.vertx.mssqlclient.MSSQLConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLClientExamples method connecting04.

public void connecting04(Vertx vertx) {
    // Connect options
    MSSQLConnectOptions connectOptions = new MSSQLConnectOptions().setPort(1433).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
    // Pool options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
    // Create the pooled client
    MSSQLPool client = MSSQLPool.pool(vertx, connectOptions, poolOptions);
    // Get a connection from the pool
    client.getConnection().compose(conn -> {
        System.out.println("Got a connection from the pool");
        // All operations execute on the same connection
        return conn.query("SELECT * FROM users WHERE id='julien'").execute().compose(res -> conn.query("SELECT * FROM users WHERE id='emad'").execute()).onComplete(ar -> {
            // Release the connection to the pool
            conn.close();
        });
    }).onComplete(ar -> {
        if (ar.succeeded()) {
            System.out.println("Done");
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
Also used : io.vertx.sqlclient(io.vertx.sqlclient) MSSQLConnection(io.vertx.mssqlclient.MSSQLConnection) Source(io.vertx.docgen.Source) Map(java.util.Map) Vertx(io.vertx.core.Vertx) NullValue(io.vertx.sqlclient.data.NullValue) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool) Collector(java.util.stream.Collector) PemTrustOptions(io.vertx.core.net.PemTrustOptions) Collectors(java.util.stream.Collectors) MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Example 14 with MSSQLConnectOptions

use of io.vertx.mssqlclient.MSSQLConnectOptions in project vertx-sql-client by eclipse-vertx.

the class MSSQLClientExamples method connecting02.

public void connecting02(Vertx vertx) {
    // Connect options
    MSSQLConnectOptions connectOptions = new MSSQLConnectOptions().setPort(1433).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
    // Pool options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
    // Create the pooled client
    MSSQLPool client = MSSQLPool.pool(vertx, connectOptions, poolOptions);
}
Also used : MSSQLConnectOptions(io.vertx.mssqlclient.MSSQLConnectOptions) MSSQLPool(io.vertx.mssqlclient.MSSQLPool)

Aggregations

MSSQLConnectOptions (io.vertx.mssqlclient.MSSQLConnectOptions)14 MSSQLPool (io.vertx.mssqlclient.MSSQLPool)6 Test (org.junit.Test)4 Vertx (io.vertx.core.Vertx)2 PoolOptions (io.vertx.sqlclient.PoolOptions)2 SqlConnectOptions (io.vertx.sqlclient.SqlConnectOptions)2 Collectors (java.util.stream.Collectors)2 CredentialsProvider (io.quarkus.credentials.CredentialsProvider)1 CloseFuture (io.vertx.core.impl.CloseFuture)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 JsonObject (io.vertx.core.json.JsonObject)1 PemTrustOptions (io.vertx.core.net.PemTrustOptions)1 ClientMetrics (io.vertx.core.spi.metrics.ClientMetrics)1 VertxMetrics (io.vertx.core.spi.metrics.VertxMetrics)1 Source (io.vertx.docgen.Source)1 MSSQLConnection (io.vertx.mssqlclient.MSSQLConnection)1 MSSQLConnectionFactory (io.vertx.mssqlclient.impl.MSSQLConnectionFactory)1 MSSQLConnectionImpl (io.vertx.mssqlclient.impl.MSSQLConnectionImpl)1 MSSQLConnectionUriParser (io.vertx.mssqlclient.impl.MSSQLConnectionUriParser)1