Codota Logo
io.vertx.rxjava.ext.jdbc
Code IndexAdd Codota to your IDE (free)

How to use io.vertx.rxjava.ext.jdbc

Best Java code snippets using io.vertx.rxjava.ext.jdbc (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  JsonObject config = new JsonObject().put("url", "jdbc:hsqldb:mem:test?shutdown=true")
   .put("driver_class", "org.hsqldb.jdbcDriver");

  JDBCClient jdbc = JDBCClient.createShared(vertx, config);

  // Connect to the database
  jdbc.rxGetConnection().flatMap(conn -> {

   // Now chain some statements using flatmap composition
   Single<ResultSet> resa = conn.rxUpdate("CREATE TABLE test(col VARCHAR(20))")
    .flatMap(result -> conn.rxUpdate("INSERT INTO test (col) VALUES ('val1')"))
    .flatMap(result -> conn.rxUpdate("INSERT INTO test (col) VALUES ('val2')"))
    .flatMap(result -> conn.rxQuery("SELECT * FROM test"));

   return resa.doAfterTerminate(conn::close);

  }).subscribe(resultSet -> {
   // Subscribe to the final result
   System.out.println("Results : " + resultSet.getRows());
  }, err -> {
   System.out.println("Database problem");
   err.printStackTrace();
  });
 }
}
origin: io.vertx/vertx-rx-java

 public static  JDBCClient newInstance(io.vertx.ext.jdbc.JDBCClient arg) {
  return arg != null ? new JDBCClient(arg) : null;
 }
}
origin: io.vertx/vertx-rx-java

 public void handle(AsyncResult<io.vertx.ext.jdbc.JDBCClient> ar) {
  if (ar.succeeded()) {
   resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(ar.result())));
  } else {
   resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
  }
 }
});
origin: sczyh30/vertx-blueprint-microservice

public CartEventDataSourceImpl(io.vertx.core.Vertx vertx, JsonObject json) {
 this.client = JDBCClient.createNonShared(Vertx.newInstance(vertx), json);
 // TODO: Should not init the table here.
 client.rxGetConnection()
  .flatMap(connection ->
   connection.rxExecute(INIT_STATEMENT)
    .doAfterTerminate(connection::close)
  )
  .subscribe();
}
origin: io.vertx/vertx-rx-java

/**
 * Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by
 * getting a connection from the pool (this object) and return it back after the execution. Only the first result
 * from the result set is returned.
 * @param sql the statement to execute
 * @return self
 */
public Single<JsonArray> rxQuerySingle(String sql) { 
 return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
  querySingle(sql, fut);
 }));
}
origin: vert-x3/vertx-rx

 /**
 * Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the
 * boilerplate code by getting a connection from the pool (this object) and return it back after the execution.
 * Only the first result from the result set is returned.
 * @param sql the statement to execute
 * @param arguments the arguments
 * @return self
 */
public Single<JsonArray> rxQuerySingleWithParams(String sql, JsonArray arguments) { 
 return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
  querySingleWithParams(sql, arguments, fut);
 }));
}
origin: io.vertx/vertx-rx-java

/**
 * Create a JDBC auth provider implementation
 * @param vertx 
 * @param client the JDBC client instance
 * @return the auth provider
 */
public static io.vertx.rxjava.ext.auth.jdbc.JDBCAuth create(io.vertx.rxjava.core.Vertx vertx, io.vertx.rxjava.ext.jdbc.JDBCClient client) { 
 io.vertx.rxjava.ext.auth.jdbc.JDBCAuth ret = io.vertx.rxjava.ext.auth.jdbc.JDBCAuth.newInstance(io.vertx.ext.auth.jdbc.JDBCAuth.create(vertx.getDelegate(), client.getDelegate()));
 return ret;
}
origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  JsonObject config = new JsonObject().put("url", "jdbc:hsqldb:mem:test?shutdown=true")
   .put("driver_class", "org.hsqldb.jdbcDriver");

  JDBCClient jdbc = JDBCClient.createShared(vertx, config);

  jdbc
   .rxGetConnection() // Connect to the database
   .flatMapObservable(conn -> { // With the connection...
    return conn.rxUpdate("CREATE TABLE test(col VARCHAR(20))") // ...create test table
     .flatMap(result -> conn.rxUpdate("INSERT INTO test (col) VALUES ('val1')")) // ...insert a row
     .flatMap(result -> conn.rxUpdate("INSERT INTO test (col) VALUES ('val2')")) // ...another one
     .flatMap(result -> conn.rxQueryStream("SELECT * FROM test")) // ...get values stream
     .flatMapObservable(sqlRowStream -> {
      return sqlRowStream.toObservable() // Transform the stream into an Observable...
       .doOnTerminate(conn::close); // ...and close the connection when the stream is fully read or an error occurs
     });
   }).subscribe(row -> System.out.println("Row : " + row.encode()));
 }
}
origin: io.vertx/vertx-rx-java

 public void handle(AsyncResult<io.vertx.ext.jdbc.JDBCClient> ar) {
  if (ar.succeeded()) {
   resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(ar.result())));
  } else {
   resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
  }
 }
});
origin: vert-x3/vertx-rx

 public static  JDBCClient newInstance(io.vertx.ext.jdbc.JDBCClient arg) {
  return arg != null ? new JDBCClient(arg) : null;
 }
}
origin: vert-x3/vertx-rx

 /**
 * Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by
 * getting a connection from the pool (this object) and return it back after the execution. Only the first result
 * from the result set is returned.
 * @param sql the statement to execute
 * @return self
 */
public Single<JsonArray> rxQuerySingle(String sql) { 
 return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
  querySingle(sql, fut);
 }));
}
origin: io.vertx/vertx-rx-java

/**
 * Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the
 * boilerplate code by getting a connection from the pool (this object) and return it back after the execution.
 * Only the first result from the result set is returned.
 * @param sql the statement to execute
 * @param arguments the arguments
 * @return self
 */
public Single<JsonArray> rxQuerySingleWithParams(String sql, JsonArray arguments) { 
 return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
  querySingleWithParams(sql, arguments, fut);
 }));
}
origin: vert-x3/vertx-examples

 "datetime TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL)";
JDBCClient client = JDBCClient.createShared(vertx, config);
 .rxGetConnection()
 .flatMap(conn ->
  conn
origin: io.vertx/vertx-rx-java

 public void handle(AsyncResult<io.vertx.ext.jdbc.JDBCClient> ar) {
  if (ar.succeeded()) {
   resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(ar.result())));
  } else {
   resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
  }
 }
});
origin: vert-x3/vertx-rx

/**
 * Create a JDBC client which shares its data source with any other JDBC clients created with the same
 * data source name
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @param dataSourceName the data source name
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config, String dataSourceName) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createShared(vertx.getDelegate(), config, dataSourceName));
 return ret;
}
origin: io.vertx/vertx-rx-java

/**
 * Like {@link io.vertx.rxjava.ext.jdbc.JDBCClient#createShared} but with the default data source name
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createShared(vertx.getDelegate(), config));
 return ret;
}
origin: vert-x3/vertx-rx

/**
 * Like {@link io.vertx.rxjava.ext.jdbc.JDBCClient#createShared} but with the default data source name
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createShared(vertx.getDelegate(), config));
 return ret;
}
origin: vert-x3/vertx-rx

/**
 * Create a JDBC client which maintains its own data source.
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createNonShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createNonShared(vertx.getDelegate(), config));
 return ret;
}
origin: io.vertx/vertx-rx-java

/**
 * Create a JDBC client which maintains its own data source.
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createNonShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createNonShared(vertx.getDelegate(), config));
 return ret;
}
origin: io.vertx/vertx-rx-java

/**
 * Create a JDBC client which shares its data source with any other JDBC clients created with the same
 * data source name
 * @param vertx the Vert.x instance
 * @param config the configuration
 * @param dataSourceName the data source name
 * @return the client
 */
public static io.vertx.rxjava.ext.jdbc.JDBCClient createShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config, String dataSourceName) { 
 io.vertx.rxjava.ext.jdbc.JDBCClient ret = io.vertx.rxjava.ext.jdbc.JDBCClient.newInstance(io.vertx.ext.jdbc.JDBCClient.createShared(vertx.getDelegate(), config, dataSourceName));
 return ret;
}
io.vertx.rxjava.ext.jdbc

Most used classes

  • JDBCClient
    An asynchronous client interface for interacting with a JDBC compliant database NOTE: This class ha
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now