protected static void executeCommand()

in quickstart/src/main/java/com/microsoft/azure/kusto/quickstart/Utils.java [159:190]


        protected static void executeCommand(Client kustoClient, String databaseName, String command) {
            ClientRequestProperties clientRequestProperties = command.startsWith(MgmtPrefix) ? createClientRequestProperties("Java_SampleApp_ControlCommand")
                    : createClientRequestProperties("Java_SampleApp_Query");
            KustoOperationResult result;

            try {
                result = command.startsWith(MgmtPrefix) ? kustoClient.executeMgmt(databaseName, command, clientRequestProperties)
                        : kustoClient.executeQuery(databaseName, command, clientRequestProperties);
                System.out.printf("Response from executed command '%s':%n", command);
                KustoResultSetTable primaryResults = result.getPrimaryResults();

                for (int rowNum = 1; primaryResults.next(); rowNum++) {
                    KustoResultColumn[] columns = primaryResults.getColumns();
                    List<Object> currentRow = primaryResults.getCurrentRow();
                    System.out.printf("Record %s%n", rowNum);

                    for (int j = 0; j < currentRow.size(); j++) {
                        Object cell = currentRow.get(j);
                        System.out.printf("Column: '%s' of type '%s', Value: '%s'%n", columns[j].getColumnName(), columns[j].getColumnType(),
                                cell == null ? "[null]" : cell);
                    }

                    System.out.println();
                }
            } catch (DataServiceException e) {
                errorHandler(String.format("Server error while trying to execute query '%s' on database '%s'%n%n", command, databaseName), e);
            } catch (DataClientException e) {
                errorHandler(String.format("Client error while trying to execute query '%s' on database '%s'%n%n", command, databaseName), e);
            } catch (Exception e) {
                errorHandler(String.format("Unexpected error while trying to execute query '%s' on database '%s'%n%n", command, databaseName), e);
            }
        }