本文整理汇总了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);
}
});
}
示例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);
}
}
示例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);
}
});
}
示例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());
}
}
示例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);
}
示例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)
);
}
示例7: MySqlAsyncConnection
import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
public MySqlAsyncConnection(final MySQLConnection conn) {
this.conn = conn;
}
示例8: getInnerConnection
import com.github.mauricio.async.db.mysql.MySQLConnection; //导入依赖的package包/类
MySQLConnection getInnerConnection() {
return conn;
}
示例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);
}
示例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);
}