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

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

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

SQLConnection.batchWithParams介绍

[英]Batch a prepared statement with all entries from the args list. Each entry is a batch. The operation completes with the execution of the batch where the async result contains a array of Integers.
[中]用args列表中的所有条目批处理准备好的语句。每个条目都是一个批次。在异步结果包含整数数组的批处理执行后,操作完成。

代码示例

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

/**
 * Batch a prepared statement with all entries from the args list. Each entry is a batch.
 * The operation completes with the execution of the batch where the async result contains a array of Integers.
 * @param sqlStatement sql statement
 * @param args the prepared statement arguments
 * @param handler the result handler
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection batchWithParams(String sqlStatement, List<JsonArray> args, Handler<AsyncResult<List<Integer>>> handler) { 
 delegate.batchWithParams(sqlStatement, args, handler);
 return this;
}

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

/**
 * Batch a prepared statement with all entries from the args list. Each entry is a batch.
 * The operation completes with the execution of the batch where the async result contains a array of Integers.
 * @param sqlStatement sql statement
 * @param args the prepared statement arguments
 * @param handler the result handler
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection batchWithParams(String sqlStatement, List<JsonArray> args, Handler<AsyncResult<List<Integer>>> handler) { 
 delegate.batchWithParams(sqlStatement, args, handler);
 return this;
}

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

@Override
public SQLConnection batchWithParams(String sqlStatement, List<JsonArray> args, Handler<AsyncResult<List<Integer>>> handler) {
 delegate.batchWithParams(sqlStatement, args, handler);
 return this;
}

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

public static io.vertx.ext.sql.SQLConnection batchWithParams(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sqlStatement, java.util.List<java.util.List<Object>> args, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler) {
 io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.batchWithParams(sqlStatement,
  args != null ? args.stream().map(elt -> elt != null ? io.vertx.core.impl.ConversionHelper.toJsonArray(elt) : null).collect(java.util.stream.Collectors.toList()) : null,
  handler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>>() {
  public void handle(io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>> ar) {
   handler.handle(ar.map(event -> event != null ? event.stream().map(elt -> elt).collect(java.util.stream.Collectors.toList()) : null));
  }
 } : null));
 return j_receiver;
}
public static io.vertx.ext.sql.SQLConnection batchCallableWithParams(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sqlStatement, java.util.List<java.util.List<Object>> inArgs, java.util.List<java.util.List<Object>> outArgs, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler) {

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

@Test
public void testBatchPreparedStatement() {
 List<String> sql = new ArrayList<>();
 sql.add("drop table if exists t");
 sql.add("create table t (u BIGINT)");
 final SQLConnection conn = connection();
 conn.batch(sql, onSuccess(batchResult -> {
  assertNotNull(batchResult);
  assertEquals(2, batchResult.size());
  List<JsonArray> args = new ArrayList<>();
  args.add(new JsonArray().add(System.currentTimeMillis()));
  args.add(new JsonArray().add(System.currentTimeMillis()));
  args.add(new JsonArray().add(System.currentTimeMillis()));
  conn.batchWithParams("insert into t (u) values (?)", args, onSuccess(batchResult2 -> {
   assertNotNull(batchResult2);
   assertEquals(3, batchResult2.size());
   testComplete();
  }));
 }));
 await();
}

相关文章