in backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java [4465:4495]
private String executeQueryOneValue(SessionPool sessionPool, String sql) throws BaseException {
SessionDataSetWrapper sessionDataSetWrapper = null;
try {
sessionDataSetWrapper = sessionPool.executeQueryStatement(sql);
int batchSize = sessionDataSetWrapper.getBatchSize();
String value = null;
if (batchSize > 0) {
while (sessionDataSetWrapper.hasNext()) {
RowRecord rowRecord = sessionDataSetWrapper.next();
List<org.apache.iotdb.tsfile.read.common.Field> fields = rowRecord.getFields();
value = fields.get(0).toString();
break;
}
}
return value;
} catch (IoTDBConnectionException e) {
logger.error(e.getMessage());
throw new BaseException(
ErrorCode.GET_SQL_ONE_VALUE_FAIL, ErrorCode.GET_SQL_ONE_VALUE_FAIL_MSG);
} catch (StatementExecutionException e) {
logger.error(e.getMessage());
if (e.getStatusCode() == 602 && sql != null && sql.contains("select")) {
throw new BaseException(
ErrorCode.NO_PRI_READ_TIMESERIES, ErrorCode.NO_PRI_READ_TIMESERIES_MSG);
}
throw new BaseException(
ErrorCode.GET_SQL_ONE_VALUE_FAIL, ErrorCode.GET_SQL_ONE_VALUE_FAIL_MSG);
} finally {
closeResultSet(sessionDataSetWrapper);
}
}