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

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

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

SQLConnection.queryStream介绍

暂无

代码示例

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

connection.queryStream("select * from test", stream -> {
 if (stream.succeeded()) {
  SQLRowStream sqlRowStream = stream.result();

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

/**
 * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream.
 * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>.
 * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection queryStream(String sql, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { 
 delegate.queryStream(sql, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() {
  public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) {
   if (ar.succeeded()) {
    handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result())));
   } else {
    handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
 return this;
}

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

/**
 * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream.
 * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>.
 * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>.
 * @return 
 */
public io.vertx.rxjava.ext.sql.SQLConnection queryStream(String sql, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { 
 delegate.queryStream(sql, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() {
  public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) {
   if (ar.succeeded()) {
    handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result())));
   } else {
    handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
 return this;
}

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

@Override
public SQLConnection queryStream(String sql, Handler<AsyncResult<SQLRowStream>> handler) {
 delegate.queryStream(sql, handler);
 return this;
}

代码示例来源:origin: io.vertx/vertx-sql-common

} else {
 final SQLConnection conn = getConnection.result();
 conn.queryStream(sql, query -> {
  if (query.failed()) {
   conn.close(close -> {

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

@Test
public void testUnhandledExceptionInHandlerRowStream(TestContext testContext) {
 this.<SQLRowStream>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.queryStream("SELECT name FROM test_table", handler);
 });
}

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

@Test
public void testUnhandledExceptionInHandlerRowStream(TestContext testContext) {
 this.<SQLRowStream>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.queryStream("SELECT name FROM test_table", handler);
 });
}

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

@Test
public void testUnhandledExceptionInHandlerRowStream(TestContext testContext) {
 this.<SQLRowStream>testUnhandledExceptionInHandler(testContext, (sqlConnection, handler) -> {
  sqlConnection.queryStream("SELECT name FROM test_table", handler);
 });
}

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

public void testStreamFlowControl(Handler<SQLRowStream> initHandler, Handler<SQLRowStream> dataHandler) {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 final AtomicInteger cnt = new AtomicInteger(0);
 final long[] t = {0, 0};
 connection().queryStream(sql, onSuccess(res -> {
  res.handler(row -> {
   t[cnt.getAndIncrement()] = System.currentTimeMillis();
   dataHandler.handle(res);
  }).endHandler(v -> {
   assertEquals(2, cnt.get());
   assertTrue(t[1] - t[0] >= 1000);
   testComplete();
  }).exceptionHandler(t0 -> {
   fail(t0);
  });
  initHandler.handle(res);
 }));
 await();
}

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

setupSimpleTable(conn, ar2 -> {
 conn.queryStream("SELECT name, id FROM test_table ORDER BY name ASC", ar3 -> {
  if (ar3.failed()) {
   context.fail(ar3.cause());

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

setupSimpleTable(conn, ar2 -> {
 conn.queryStream("SELECT name, id FROM test_table ORDER BY name ASC", ar3 -> {
  if (ar3.failed()) {
   context.fail(ar3.cause());

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

setupSimpleTable(conn, ar2 -> {
 conn.queryStream("SELECT name, id FROM test_table ORDER BY name ASC", ar3 -> {
  if (ar3.failed()) {
   context.fail(ar3.cause());

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

@Test
public void testStreamGetColumns() {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 connection().queryStream(sql, onSuccess(res -> {
  assertEquals(Arrays.asList("ID", "FNAME", "LNAME"), res.columns());
  // assert the collection is immutable
  try {
   res.columns().add("durp!");
   fail();
  } catch (RuntimeException e) {
   // expected!
  }
  testComplete();
 }));
 await();
}

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

conn.queryStream("SELECT name, id FROM test_table ORDER BY name ASC", ar3 -> {
 if (ar3.failed()) {
  context.fail(ar3.cause());

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

conn.queryStream("SELECT name, id FROM test_table ORDER BY name ASC", ar3 -> {
 if (ar3.failed()) {
  context.fail(ar3.cause());

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

@Test
public void testStreamColumnResolution() {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 final AtomicInteger cnt = new AtomicInteger(0);
 connection().queryStream(sql, onSuccess(res -> {
  res.handler(row -> {
   assertEquals("doe", row.getString(res.column("lname")));
   cnt.incrementAndGet();
  }).endHandler(v -> {
   assertEquals(2, cnt.get());
   testComplete();
  }).exceptionHandler(t -> {
   fail(t);
  });
 }));
 await();
}

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

@Test
public void testBigStream() {
 String sql = "SELECT * FROM big_table";
 final AtomicInteger cnt = new AtomicInteger(0);
 connection().queryStream(sql, onSuccess(res -> {
  res.resultSetClosedHandler(v -> {
   res.moreResults();
  }).handler(row -> {
   cnt.incrementAndGet();
  }).endHandler(v -> {
   assertEquals(200, cnt.get());
   testComplete();
  }).exceptionHandler(t -> {
   fail(t);
  });
 }));
 await();
}

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

@Test
public void testStream() {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 final AtomicInteger cnt = new AtomicInteger(0);
 connection().queryStream(sql, onSuccess(res -> {
  res.resultSetClosedHandler(v -> {
   res.moreResults();
  }).handler(row -> {
   cnt.incrementAndGet();
  }).endHandler(v -> {
   assertEquals(2, cnt.get());
   testComplete();
  }).exceptionHandler(t -> {
   fail(t);
  });
 }));
 await();
}

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

@Test
public void testStreamOnClosedConnection() {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 final AtomicInteger cnt = new AtomicInteger(0);
 final SQLConnection conn = connection();
 conn.queryStream(sql, onSuccess(res -> {
  conn.close();
  res.resultSetClosedHandler(v -> {
   fail("Should not happen");
  }).handler(row -> {
   fail("Should not happen");
  }).endHandler(v -> {
   fail("Should not happen");
  }).exceptionHandler(t -> {
   testComplete();
  });
 }));
 await();
}

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

@Test
public void testStreamAbort() {
 String sql = "SELECT ID, FNAME, LNAME FROM select_table ORDER BY ID";
 connection().queryStream(sql, onSuccess(res -> {
  res.handler(row -> {
   res.close(close -> {
    testComplete();
   });
  }).endHandler(v -> {
   fail("Should not be called");
  }).exceptionHandler(t -> {
   fail(t);
  });
 }));
 await();
}

相关文章