io.vertx.ext.sql.SQLConnection.update()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中io.vertx.ext.sql.SQLConnection.update()方法的一些代码示例,展示了SQLConnection.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SQLConnection.update()方法的具体详情如下:
包路径:io.vertx.ext.sql.SQLConnection
类名称:SQLConnection
方法名:update

SQLConnection.update介绍

暂无

代码示例

代码示例来源:origin: vert-x3/vertx-examples

@Override
@Suspendable
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);
 // Get a connection
 try (SQLConnection conn = awaitResult(jdbc::getConnection)) {
  // Create a table
  Void v = awaitResult(h -> conn.execute("CREATE TABLE test(col VARCHAR(20))", h));
  // Insert some stuff
  for (int i = 0; i < 10; i++) {
   int ii = i;
   UpdateResult res = awaitResult(h -> conn.update("INSERT INTO test (col) VALUES ('val" + ii + "')", h));
   System.out.println("Rows updated: " + res.getUpdated());
  }
  // Select the results
  ResultSet res = awaitResult(h -> conn.query("SELECT * FROM test", h));
  System.out.println("Selected " + res.getNumRows() + " results");
  res.getResults().forEach(System.out::println);
 }
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Executes the given SQL statement which may be an <code>INSERT</code>, <code>UPDATE</code>, or <code>DELETE</code>
 * statement.
 * @param sql the SQL to execute. For example <code>INSERT INTO table ...</code>
 * @param resultHandler the handler which is called once the operation completes.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection update(String sql, Handler<AsyncResult<UpdateResult>> resultHandler) { 
 delegate.update(sql, resultHandler);
 return this;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Executes the given SQL statement which may be an <code>INSERT</code>, <code>UPDATE</code>, or <code>DELETE</code>
 * statement.
 * @param sql the SQL to execute. For example <code>INSERT INTO table ...</code>
 * @param resultHandler the handler which is called once the operation completes.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection update(String sql, Handler<AsyncResult<UpdateResult>> resultHandler) { 
 delegate.update(sql, resultHandler);
 return this;
}

代码示例来源:origin: io.vertx/vertx-lang-groovy

public static io.vertx.ext.sql.SQLConnection update(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
 io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.update(sql,
  resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.sql.UpdateResult>>() {
  public void handle(io.vertx.core.AsyncResult<io.vertx.ext.sql.UpdateResult> ar) {
   resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null));
  }
 } : null));
 return j_receiver;
}
public static io.vertx.ext.sql.SQLConnection updateWithParams(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sql, java.util.List<Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Override
public SQLConnection update(String sql, Handler<AsyncResult<UpdateResult>> resultHandler) {
 delegate.update(sql, resultHandler);
 return this;
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

protected void removeAll(String sql, Handler<AsyncResult<Void>> resultHandler) {
 client.getConnection(connHandler(resultHandler, connection -> {
  connection.update(sql, r -> {
   if (r.succeeded()) {
    resultHandler.handle(Future.succeededFuture());
   } else {
    resultHandler.handle(Future.failedFuture(r.cause()));
   }
   connection.close();
  });
 }));
}

代码示例来源:origin: io.github.jklingsporn/vertx-jooq-async-future

@Override
public CompletableFuture<Long> insertReturning(Query query) {
  return getConnection().thenCompose(sqlConnection -> {
    CompletableFuture<Long> cf = new VertxCompletableFuture<>(vertx);
    sqlConnection.update(query.getSQL(ParamType.INLINED), executeAndClose(updateResult->updateResult.getKeys().getLong(0), sqlConnection, cf));
    return cf;
  });
}

代码示例来源:origin: jklingsporn/vertx-jooq-async

@Override
public CompletableFuture<Long> insertReturning(Query query) {
  return getConnection().thenCompose(sqlConnection -> {
    CompletableFuture<Long> cf = new VertxCompletableFuture<>(vertx);
    sqlConnection.update(query.getSQL(ParamType.INLINED), executeAndClose(updateResult->updateResult.getKeys().getLong(0), sqlConnection, cf));
    return cf;
  });
}

代码示例来源:origin: io.vertx/vertx-mysql-postgresql-client-jasync

@Test
public void testUnhandledExceptionInHandlerUpdateResult(TestContext testContext) {
 this.<UpdateResult>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.update("INSERT INTO test_table (name) VALUES ('pimpo')", handler);
 });
}

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

@Test
public void testUnhandledExceptionInHandlerUpdateResult(TestContext testContext) {
 this.<UpdateResult>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.update("INSERT INTO test_table (name) VALUES ('pimpo')", handler);
 });
}

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

@Test
public void testUnhandledExceptionInHandlerUpdateResult(TestContext testContext) {
 this.<UpdateResult>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.update("INSERT INTO test_table (name) VALUES ('pimpo')", handler);
 });
}

代码示例来源:origin: io.vertx/vertx-mysql-postgresql-client-jasync

private void setupTestTable(SQLConnection conn, Supplier<String> idNameValuesSupplier, Handler<AsyncResult<Void>> handler) {
 conn.execute("BEGIN",
  ar -> conn.execute("DROP TABLE IF EXISTS test_table",
   ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
    ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + idNameValuesSupplier.get(),
     ar4 -> conn.execute("COMMIT", handler)))));
}

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

private void setupTestTable(SQLConnection conn, Supplier<String> idNameValuesSupplier, Handler<AsyncResult<Void>> handler) {
 conn.execute("BEGIN",
  ar -> conn.execute("DROP TABLE IF EXISTS test_table",
   ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
    ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + idNameValuesSupplier.get(),
     ar4 -> conn.execute("COMMIT", handler)))));
}

代码示例来源:origin: io.vertx/vertx-mysql-postgresql-client-jasync

private void setupSimpleTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
 conn.execute("BEGIN",
  ar -> conn.execute("DROP TABLE IF EXISTS test_table",
   ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
    ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + Data.get(),
     ar4 -> conn.execute("COMMIT", handler)))));
}

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

private void setupSimpleTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
 conn.execute("BEGIN",
  ar -> conn.execute("DROP TABLE IF EXISTS test_table",
   ar2 -> conn.execute(CREATE_TABLE_STATEMENT,
    ar3 -> conn.update("INSERT INTO test_table (id, name) VALUES " + Data.get(),
     ar4 -> conn.execute("COMMIT", handler)))));
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testNaturalInsert() {
 String sql = "INSERT INTO insert_table2 VALUES (1, 'doe', 'john', '2001-01-01');";
 connection().update(sql, onSuccess(result -> {
  assertUpdate(result, 1);
  testComplete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testInsert() {
 String sql = "INSERT INTO insert_table VALUES (null, 'doe', 'john', '2001-01-01');";
 connection().update(sql, onSuccess(result -> {
  assertUpdate(result, 1);
  testComplete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testUpdateNoMatch() {
 SQLConnection conn = connection();
 String sql = "UPDATE update_table SET fname='jane' WHERE id = -231";
 conn.update(sql, onSuccess(result -> {
  assertUpdate(result, 0);
  testComplete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testDelete() {
 String sql = "DELETE FROM delete_table WHERE id = 1;";
 connection().update(sql, onSuccess(result -> {
  assertNotNull(result);
  assertEquals(1, result.getUpdated());
  testComplete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-jdbc-client

@Test
public void testReturnIds() {
 connection().update("insert into customers(firstname, lastname) values('Paulo', 'Lopes')", onSuccess(updateResult -> {
  assertNotNull(updateResult);
  assertNotNull(updateResult.getKeys());
  assertTrue(updateResult.getKeys().size() > 0);
  testComplete();
 }));
 await();
}

相关文章