Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main.com.safenetpay.thirdproject;
- import io.vertx.core.Vertx;
- import io.vertx.pgclient.PgConnectOptions;
- import io.vertx.pgclient.PgPool;
- import io.vertx.sqlclient.PoolOptions;
- public class PersonDao {
- PgConnectOptions connectOptions;
- PoolOptions poolOptions;
- PgPool client;
- public PersonDao(Vertx vertx) {
- connectOptions = new PgConnectOptions().setPort(5432).setHost("localhost").setDatabase("db").setUser("postgres")
- .setPassword("postgres");
- poolOptions = new PoolOptions().setMaxSize(5);
- client = PgPool.pool(vertx, connectOptions, poolOptions);
- }
- public void getPersons() {
- client.query("SELECT * FROM db").execute(res->{
- try {
- if (res.succeeded()) {
- System.out.println(res.result());
- } else {
- System.out.println("Failure: " + res.cause().getMessage());
- }
- } catch (Exception e) {
- System.out.println(e);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment