use of com.mysql.cj.protocol.x.Notice in project wandaxin-vehicle-manage by Jarrettluo.
the class WandaxinVehicleManageApplicationTests method TestHttpRequest.
@Test
public void TestHttpRequest() {
String url = "http://118.31.113.49/api/vin/v2/index?key=d7ba9fa7634764f2fd5bb81e8183ce18&vin=LFV2A21K363553763";
RestTemplate restTemplate = new RestTemplate();
// 将指定的url返回的参数自动封装到自定义好的对应类对象中
Notice notice = restTemplate.getForObject(url, Notice.class);
System.out.println(notice);
}
use of com.mysql.cj.protocol.x.Notice in project aws-mysql-jdbc by awslabs.
the class SqlResultBuilder method addProtocolEntity.
@Override
public boolean addProtocolEntity(ProtocolEntity entity) {
if (entity instanceof Field) {
this.fields.add((Field) entity);
if (!this.isRowResult) {
this.isRowResult = true;
}
this.prevEntity = entity;
return false;
} else if (entity instanceof Notice) {
this.statementExecuteOkBuilder.addProtocolEntity(entity);
return false;
}
if (this.isRowResult && this.metadata == null) {
this.metadata = new DefaultColumnDefinition(this.fields.toArray(new Field[] {}));
}
if (entity instanceof Row) {
this.rows.add(((Row) entity).setMetadata(this.metadata));
} else if (entity instanceof FetchDoneMoreResults) {
this.resultSets.add(new SqlSingleResult(this.metadata, this.defaultTimeZone, new BufferedRowList(this.rows), () -> this.statementExecuteOkBuilder.build(), this.pset));
// clear variables to accept next result set
this.fields = new ArrayList<>();
this.metadata = null;
this.rows = new ArrayList<>();
this.statementExecuteOkBuilder = new StatementExecuteOkBuilder();
} else if (entity instanceof FetchDoneEntity) {
if (this.prevEntity instanceof FetchDoneMoreResults) {
// no-op, possibly bug in xplugin sending FetchDone immediately following FetchDoneMoreResultsets
} else {
this.resultSets.add(new SqlSingleResult(this.metadata, this.defaultTimeZone, new BufferedRowList(this.rows), () -> this.statementExecuteOkBuilder.build(), this.pset));
}
} else if (entity instanceof StatementExecuteOk) {
return true;
}
this.prevEntity = entity;
return false;
}
use of com.mysql.cj.protocol.x.Notice in project aws-mysql-jdbc by awslabs.
the class StreamingSqlResultBuilder method addProtocolEntity.
@Override
public boolean addProtocolEntity(ProtocolEntity entity) {
if (entity instanceof Notice) {
this.statementExecuteOkBuilder.addProtocolEntity(entity);
} else {
this.lastEntity = entity;
}
AtomicBoolean readLastResult = new AtomicBoolean(false);
Supplier<ProtocolEntity> okReader = () -> {
if (readLastResult.get()) {
throw new CJCommunicationsException("Invalid state attempting to read ok packet");
}
if (this.protocol.hasMoreResults()) {
StatementExecuteOk res = this.statementExecuteOkBuilder.build();
this.statementExecuteOkBuilder = new StatementExecuteOkBuilder();
return res;
}
readLastResult.set(true);
return this.protocol.readQueryResult(this.statementExecuteOkBuilder);
};
Supplier<SqlResult> resultStream = () -> {
if (readLastResult.get()) {
return null;
} else if (this.lastEntity != null && this.lastEntity instanceof Field || this.protocol.isSqlResultPending()) {
ColumnDefinition cd;
if (this.lastEntity != null && this.lastEntity instanceof Field) {
cd = this.protocol.readMetadata((Field) this.lastEntity, (n) -> {
this.statementExecuteOkBuilder.addProtocolEntity(n);
});
this.lastEntity = null;
} else {
cd = this.protocol.readMetadata(this.statementExecuteOkBuilder::addProtocolEntity);
}
return new SqlSingleResult(cd, this.protocol.getServerSession().getDefaultTimeZone(), new XProtocolRowInputStream(cd, this.protocol, (n) -> {
this.statementExecuteOkBuilder.addProtocolEntity(n);
}), okReader, this.pset);
} else {
readLastResult.set(true);
SqlResultBuilder rb = new SqlResultBuilder(this.defaultTimeZone, this.pset);
rb.addProtocolEntity(entity);
return this.protocol.readQueryResult(rb);
}
};
this.result = new SqlMultiResult(resultStream);
return true;
}
Aggregations