package examples;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.asyncsql.MySQLClient;
import io.vertx.ext.asyncsql.PostgreSQLClient;
import io.vertx.ext.sql.SQLClient;
import io.vertx.ext.sql.SQLConnection;
public class MySQLPostgreSQLExamples {
public void exampleCreateDefault(Vertx vertx) {
JsonObject mySQLClientConfig = new JsonObject().put("host", "mymysqldb.mycompany");
SQLClient mySQLClient = MySQLClient.createShared(vertx, mySQLClientConfig);
JsonObject postgreSQLClientConfig = new JsonObject().put("host", "mypostgresqldb.mycompany");
SQLClient postgreSQLClient = PostgreSQLClient.createShared(vertx, postgreSQLClientConfig);
}
public void exampleCreatePoolName(Vertx vertx) {
JsonObject mySQLClientConfig = new JsonObject().put("host", "mymysqldb.mycompany");
SQLClient mySQLClient = MySQLClient.createShared(vertx, mySQLClientConfig, "MySQLPool1");
JsonObject postgreSQLClientConfig = new JsonObject().put("host", "mypostgresqldb.mycompany");
SQLClient postgreSQLClient = PostgreSQLClient.createShared(vertx, postgreSQLClientConfig, "PostgreSQLPool1");
}
public void exampleCreateNonShared(Vertx vertx) {
JsonObject mySQLClientConfig = new JsonObject().put("host", "mymysqldb.mycompany");
SQLClient mySQLClient = MySQLClient.createNonShared(vertx, mySQLClientConfig);
JsonObject postgreSQLClientConfig = new JsonObject().put("host", "mypostgresqldb.mycompany");
SQLClient postgreSQLClient = PostgreSQLClient.createNonShared(vertx, postgreSQLClientConfig);
}
public void example2(Vertx vertx) {
JsonObject config = new JsonObject().put("host", "mymysqldb.mycompany");
SQLClient mySQLClient = MySQLClient.createNonShared(vertx, config);
}
public void example3(Vertx vertx) {
JsonObject config = new JsonObject().put("host", "mypostgresqldb.mycompany");
SQLClient postgreSQLClient = PostgreSQLClient.createNonShared(vertx, config);
}
public void example4(SQLClient client) {
client.getConnection(res -> {
if (res.succeeded()) {
SQLConnection connection = res.result();
} else {
}
});
}
}