与 AWS SDK ExecuteGremlinProfileQuery 配合使用 - AWS SDK 代码示例

文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

与 AWS SDK ExecuteGremlinProfileQuery 配合使用

以下代码示例演示了如何使用 ExecuteGremlinProfileQuery

Java
适用于 Java 的 SDK 2.x
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

/** * Executes a Gremlin query against an Amazon Neptune database using the provided {@link NeptunedataClient}. * * @param client the {@link NeptunedataClient} instance to use for executing the Gremlin query */ public static void executeGremlinQuery(NeptunedataClient client) { try { System.out.println("Querying Neptune..."); ExecuteGremlinQueryRequest request = ExecuteGremlinQueryRequest.builder() .gremlinQuery("g.V().has('code', 'ANC')") .build(); ExecuteGremlinQueryResponse response = client.executeGremlinQuery(request); System.out.println("Full Response:"); System.out.println(response); // Retrieve and print the result if (response.result() != null) { System.out.println("Query Result:"); System.out.println(response.result().toString()); } else { System.out.println("No result returned from the query."); } } catch (NeptunedataException e) { System.err.println("Error calling Neptune: " + e.awsErrorDetails().errorMessage()); } catch (Exception e) { System.err.println("Unexpected error: " + e.getMessage()); } finally { client.close(); } }