use of io.mycat.newquery.MysqlCollector in project Mycat2 by MyCATApache.
the class VertxExecuter method runQueryOutputAsMysqlPayloadObject.
public static Observable<MysqlPayloadObject> runQueryOutputAsMysqlPayloadObject(Future<NewMycatConnection> connectionFuture, String sql, List<Object> values) {
return Observable.create(emitter -> {
// 连接到达
connectionFuture.onSuccess(connection -> {
// 预编译到达
connection.prepareQuery(sql, values, new MysqlCollector() {
MycatRowMetaData mycatRowMetaData;
@Override
public void onColumnDef(MycatRowMetaData mycatRowMetaData) {
emitter.onNext(new MySQLColumnDef(this.mycatRowMetaData = mycatRowMetaData));
}
@Override
public void onRow(Object[] row) {
emitter.onNext(new MysqlObjectArrayRow(BaseRowObservable.getObjects(row, this.mycatRowMetaData)));
}
@Override
public void onComplete() {
emitter.onComplete();
}
@Override
public void onError(Throwable e) {
emitter.onError(e);
}
});
});
connectionFuture.onFailure(i -> emitter.onError(i));
});
}
use of io.mycat.newquery.MysqlCollector in project Mycat2 by MyCATApache.
the class VertxExecuter method runQuery.
public static Observable<Object[]> runQuery(Future<NewMycatConnection> connectionFuture, String sql, List<Object> values, MycatRowMetaData rowMetaDataArg) {
return Observable.create(emitter -> {
// 连接到达
connectionFuture.onSuccess(connection -> {
// 预编译到达
connection.prepareQuery(sql, values, new MysqlCollector() {
MycatRowMetaData mycatRowMetaData;
@Override
public void onColumnDef(MycatRowMetaData mycatRowMetaData) {
this.mycatRowMetaData = Optional.ofNullable(rowMetaDataArg).orElse(mycatRowMetaData);
}
@Override
public void onRow(Object[] row) {
try {
emitter.onNext(BaseRowObservable.getObjects(row, this.mycatRowMetaData));
} catch (Exception e) {
LOGGER.error("", e);
throw e;
}
}
@Override
public void onComplete() {
emitter.onComplete();
}
@Override
public void onError(Throwable e) {
emitter.onError(e);
}
});
});
connectionFuture.onFailure(i -> emitter.onError(i));
});
}
Aggregations