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

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

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

SQLConnection.close介绍

[英]Closes the connection. Important to always close the connection when you are done so it's returned to the pool.
[中]关闭连接。完成后务必关闭连接,以便将其返回到池中。

代码示例

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

connection.close(done -> {
 if (done.failed()) {
  resultHandler.handle(Future.failedFuture(done.cause()));

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

connection.close(done -> {
 if (done.failed()) {
  throw new RuntimeException(done.cause());

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

connection.close(done -> {
 if (done.failed()) {
  throw new RuntimeException(done.cause());

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

conn.result().close(done -> {
 if (done.failed()) {
  throw new RuntimeException(done.cause());

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

conn.result().close(done -> {
 if (done.failed()) {
  throw new RuntimeException(done.cause());

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

.endHandler(v -> {
 connection.close(done -> {
  if (done.failed()) {
   throw new RuntimeException(done.cause());

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

routingContext.addHeadersEndHandler(done -> conn.close(v -> { }));
SQLConnection conn = routingContext.get("conn");
if (conn != null) {
 conn.close(v -> {
 });

代码示例来源:origin: apiman/apiman

@Override
public void close() throws Exception {
  connection.close();
  closed = true;
}

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

/**
 * Closes the connection. Important to always close the connection when you are done so it's returned to the pool.
 * @param handler the handler called when this operation completes.
 */
public void close(Handler<AsyncResult<Void>> handler) { 
 delegate.close(handler);
}

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

/**
 * Closes the connection. Important to always close the connection when you are done so it's returned to the pool.
 */
public void close() { 
 delegate.close();
}

代码示例来源:origin: apiman/apiman

@Override
public void close(IAsyncResultHandler<Void> handler) {
  connection.close(translateVoidHandlers(handler));
  closed = true;
}

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

protected <U> Function<SQLConnection,CompletableFuture<U>> safeExecute(Function<SQLConnection,CompletableFuture<U>> action){
  return sqlConnection -> {
    try{
      return action.apply(sqlConnection);
    }catch(Throwable e){
      sqlConnection.close();
      CompletableFuture<U> cf = new VertxCompletableFuture<>(vertx);
      cf.completeExceptionally(e);
      return cf;
    }
  };
}

代码示例来源: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: sczyh30/vertx-blueprint-microservice

protected <R> void execute(JsonArray params, String sql, R ret, Handler<AsyncResult<R>> resultHandler) {
 client.getConnection(connHandler(resultHandler, connection -> {
  connection.updateWithParams(sql, params, r -> {
   if (r.succeeded()) {
    resultHandler.handle(Future.succeededFuture(ret));
   } else {
    resultHandler.handle(Future.failedFuture(r.cause()));
   }
   connection.close();
  });
 }));
}

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

@Override
public void initializePersistence(Handler<AsyncResult<Void>> resultHandler) {
 jdbc.getConnection(connHandler(resultHandler, connection -> {
  connection.execute(CREATE_STATEMENT, r -> {
   resultHandler.handle(r);
   connection.close();
  });
 }));
}

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

@Override
public ProductService initializePersistence(Handler<AsyncResult<Void>> resultHandler) {
 client.getConnection(connHandler(resultHandler, connection -> {
  connection.execute(CREATE_STATEMENT, r -> {
   resultHandler.handle(r);
   connection.close();
  });
 }));
 return this;
}

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

@Override
public AccountService initializePersistence(Handler<AsyncResult<Void>> resultHandler) {
 client.getConnection(connHandler(resultHandler, connection -> {
  connection.execute(CREATE_STATEMENT, r -> {
   resultHandler.handle(r);
   connection.close();
  });
 }));
 return this;
}

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

@Override
public OrderService initializePersistence(Handler<AsyncResult<Void>> resultHandler) {
 client.getConnection(connHandler(resultHandler, connection -> {
  connection.execute(CREATE_STATEMENT, r -> {
   resultHandler.handle(r);
   connection.close();
  });
 }));
 return this;
}

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

@Test
public void testCloseThenQuery() throws Exception {
 client.getConnection(onSuccess(conn -> {
  conn.close(onSuccess(v -> {
   conn.query("SELECT 1 FROM select_table", onFailure(t -> {
    assertNotNull(t);
    testComplete();
   }));
  }));
 }));
 await();
}

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

@Test
public void testClose() throws Exception {
 client.getConnection(onSuccess(conn -> {
  conn.query("SELECT 1 FROM select_table", onSuccess(results -> {
   assertNotNull(results);
   conn.close(onSuccess(v -> {
    testComplete();
   }));
  }));
 }));
 await();
}

相关文章