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);
}
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();
});
}
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());
}
});
}
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);
}
Aggregations