use of io.vertx.sqlclient.SqlClient in project vertx-sql-client by eclipse-vertx.
the class DB2ClientExamples method connecting02.
public void connecting02(Vertx vertx) {
// Connect options
DB2ConnectOptions connectOptions = new DB2ConnectOptions().setPort(50000).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
// Pool options
PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
// Create the pooled client
SqlClient client = DB2Pool.client(vertx, connectOptions, poolOptions);
}
use of io.vertx.sqlclient.SqlClient in project vertx-sql-client by eclipse-vertx.
the class DB2ClientExamples method connecting01.
public void connecting01() {
// Connect options
DB2ConnectOptions connectOptions = new DB2ConnectOptions().setPort(50000).setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret");
// Pool options
PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
// Create the pooled client
SqlClient client = DB2Pool.client(connectOptions, poolOptions);
}
use of io.vertx.sqlclient.SqlClient in project vertx-sql-client by eclipse-vertx.
the class DB2ClientExamples method poolVersusPooledClient.
public void poolVersusPooledClient(Vertx vertx, String sql, DB2ConnectOptions connectOptions, PoolOptions poolOptions) {
// Pooled client
SqlClient pooledClient = DB2Pool.client(vertx, connectOptions, poolOptions);
// Pipelined
Future<RowSet<Row>> res1 = pooledClient.query(sql).execute();
// Connection pool
DB2Pool pool = DB2Pool.pool(vertx, connectOptions, poolOptions);
// Not pipelined
Future<RowSet<Row>> res2 = pool.query(sql).execute();
}
use of io.vertx.sqlclient.SqlClient in project vertx-sql-client by eclipse-vertx.
the class InetCodecTest method testDecodeINET.
private void testDecodeINET(TestContext ctx, BiFunction<SqlClient, String, Query<RowSet<Row>>> a) throws Exception {
InetAddress addr1 = Inet4Address.getByName("0.1.2.3");
InetAddress addr2 = Inet6Address.getByName("2001:0db8:0a0b:12f0:0000:0000:0000:0001");
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
a.apply(conn, "SELECT " + "'0.1.2.3'::INET," + "'0.1.2.3/4'::INET," + "'2001:0db8:0a0b:12f0:0000:0000:0000:0001'::INET," + "'2001:0db8:0a0b:12f0:0000:0000:0000:0001/4'::INET").execute(ctx.asyncAssertSuccess(rows -> {
ctx.assertEquals(1, rows.size());
Row row = rows.iterator().next();
Inet v1 = (Inet) row.getValue(0);
Inet v2 = (Inet) row.getValue(1);
Inet v3 = (Inet) row.getValue(2);
Inet v4 = (Inet) row.getValue(3);
ctx.assertEquals(addr1, v1.getAddress());
ctx.assertNull(v1.getNetmask());
ctx.assertEquals(addr1, v2.getAddress());
ctx.assertEquals(4, v2.getNetmask());
ctx.assertEquals(addr2, v3.getAddress());
ctx.assertNull(v3.getNetmask());
ctx.assertEquals(addr2, v4.getAddress());
ctx.assertEquals(4, v4.getNetmask());
}));
}));
}
Aggregations