use of com.alibaba.nacos.config.server.exception.NJdbcException in project nacos by alibaba.
the class DistributedDatabaseOperateImpl method queryMany.
@Override
public List<Map<String, Object>> queryMany(String sql, Object[] args) {
try {
LoggerUtils.printIfDebugEnabled(LogUtil.DEFAULT_LOG, "queryMany info : sql : {}, args : {}", sql, args);
byte[] data = serializer.serialize(SelectRequest.builder().queryType(QueryType.QUERY_MANY_WITH_LIST_WITH_ARGS).sql(sql).args(args).build());
final boolean blockRead = EmbeddedStorageContextUtils.containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA);
Response response = innerRead(ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead);
if (response.getSuccess()) {
return serializer.deserialize(response.getData().toByteArray(), List.class);
}
throw new NJdbcException(response.getErrMsg());
} catch (Exception e) {
LogUtil.FATAL_LOG.error("An exception occurred during the query operation : {}", e.toString());
throw new NacosRuntimeException(NacosException.SERVER_ERROR, e.toString());
}
}
use of com.alibaba.nacos.config.server.exception.NJdbcException in project nacos by alibaba.
the class DistributedDatabaseOperateImpl method queryMany.
@Override
public <R> List<R> queryMany(String sql, Object[] args, Class<R> rClass) {
try {
LoggerUtils.printIfDebugEnabled(LogUtil.DEFAULT_LOG, "queryMany info : sql : {}, args : {}", sql, args);
byte[] data = serializer.serialize(SelectRequest.builder().queryType(QueryType.QUERY_MANY_NO_MAPPER_WITH_ARGS).sql(sql).args(args).className(rClass.getCanonicalName()).build());
final boolean blockRead = EmbeddedStorageContextUtils.containsExtendInfo(Constants.EXTEND_NEED_READ_UNTIL_HAVE_DATA);
Response response = innerRead(ReadRequest.newBuilder().setGroup(group()).setData(ByteString.copyFrom(data)).build(), blockRead);
if (response.getSuccess()) {
return serializer.deserialize(response.getData().toByteArray(), List.class);
}
throw new NJdbcException(response.getErrMsg());
} catch (Exception e) {
LogUtil.FATAL_LOG.error("An exception occurred during the query operation : {}", e.toString());
throw new NacosRuntimeException(NacosException.SERVER_ERROR, e.toString());
}
}
Aggregations