当前位置: 首页>>代码示例>>Java>>正文


Java MySQLConnection类代码示例

本文整理汇总了Java中com.github.mauricio.async.db.mysql.MySQLConnection的典型用法代码示例。如果您正苦于以下问题:Java MySQLConnection类的具体用法?Java MySQLConnection怎么用?Java MySQLConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MySQLConnection类属于com.github.mauricio.async.db.mysql包,在下文中一共展示了MySQLConnection类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connect

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
public ComposableFuture<MySqlAsyncConnection> connect() {
  if (conn.isConnected()) {
    return ComposableFutures.fromValue(this);
  }

  final ComposableFuture<Connection> composableFuture = ScalaFutureHelper.from(conn::connect);

  return composableFuture.map(result -> {
    final MySQLConnection connection = (MySQLConnection) result;
    if (connection == conn) {
      return MySqlAsyncConnection.this;
    } else {
      return new MySqlAsyncConnection(connection);
    }
  });
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:17,代码来源:MySqlAsyncConnection.java

示例2: create

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
@Override
public MySQLConnection create() {
  numOfCreations++;
  if (numOfCreations > 1) {
    throw new IllegalStateException("trying to create more that one connection per test");
  }

  final MySQLConnection conn = super.create();
  final Future<QueryResult> futureRes = conn.sendQuery("start transaction;");
  try {
    Await.result(futureRes, configuration.connectTimeout());
    return conn;
  } catch (final Exception e) {
    throw new IllegalStateException("can't start transaction on the connection", e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:17,代码来源:BasicTestingDao.java

示例3: disconnect

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
public ComposableFuture<MySqlAsyncConnection> disconnect() {
  final ComposableFuture<Connection> composableFuture = ScalaFutureHelper.from(conn::disconnect);

  return composableFuture.map(result -> {
    final MySQLConnection connection = (MySQLConnection) result;
    if (connection == conn) {
      return MySqlAsyncConnection.this;
    } else {
      return new MySqlAsyncConnection(connection);
    }
  });
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:13,代码来源:MySqlAsyncConnection.java

示例4: initializeMetrics

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
private static void initializeMetrics(final MetricFactory metricFactory, final ConnectionPool<MySQLConnection> pool) {
  if (metricFactory != null) {
    metricFactory.registerGauge("MysqlAsyncConnectionPool", "available", () -> pool.availables().size());
    metricFactory.registerGauge("MysqlAsyncConnectionPool", "waiting", () -> pool.queued().size());
    metricFactory.registerGauge("MysqlAsyncConnectionPool", "inUse", () -> pool.inUse().size());
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:8,代码来源:MySqlConnectionPool.java

示例5: validate

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
@Override
public Try<MySQLConnection> validate(final MySQLConnection item) {
  if (!item.isConnected()) {
    return new Failure<>(new ConnectionNotConnectedException(item));
  }

  if (item.isQuerying()) {
    return new Failure<>(new ConnectionStillRunningQueryException(item.count(), false));
  }

  return new Success<>(item);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:13,代码来源:BasicTestingDao.java

示例6: create

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
@Override
protected Connection create() {
  return new MySQLConnection(configuration, CharsetMapper.Instance(),
      vertx.nettyEventLoopGroup().next(),
      VertxEventLoopExecutionContext.create(vertx)
  );
}
 
开发者ID:vert-x3,项目名称:vertx-mysql-postgresql-client,代码行数:8,代码来源:MysqlAsyncConnectionPool.java

示例7: MySqlAsyncConnection

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
public MySqlAsyncConnection(final MySQLConnection conn) {
  this.conn = conn;
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:4,代码来源:MySqlAsyncConnection.java

示例8: getInnerConnection

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
MySQLConnection getInnerConnection() {
  return conn;
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:4,代码来源:MySqlAsyncConnection.java

示例9: take

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
private ComposableFuture<MySqlAsyncConnection> take() {
  final ComposableFuture<MySQLConnection> connFuture = ScalaFutureHelper.from(_pool::take);

  return connFuture.map(MySqlAsyncConnection::new);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:6,代码来源:MySqlConnectionPool.java

示例10: close

import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
@Override
public ComposableFuture<Boolean> close() {
  final ComposableFuture<AsyncObjectPool<MySQLConnection>> future = ScalaFutureHelper.from(_pool::close);
  return future.always(Try::isSuccess);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:6,代码来源:MySqlConnectionPool.java


注:本文中的com.github.mauricio.async.db.mysql.MySQLConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。