如何在不使用Datastax Studio但通过Java创建图形及其模式的情况下?

我试图通过java创建我与DSE Graph的第一个连接..

public static void main(String args[]){ DseCluster dseCluster = null; try { dseCluster = DseCluster.builder() .addContactPoint("192.168.1.43") .build(); DseSession dseSession = dseCluster.connect(); GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName("graph")); GraphStatement graphStatement = DseGraph.statementFromTraversal(g.addV("test")); GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName("graph")); System.out.println(grs.one().asVertex()); } finally { if (dseCluster != null) dseCluster.close(); } } 

起初我得到的“图形”不存在..我必须通过DataStax Studio创建与特定图形的连接,因为它不在那里。

现在我需要在模式中放置标签,属性等。我知道如何在工作室中进行操作( https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/using/createSchemaStudio.html )但我想在代码中这样做。 如何在Java中访问模式对象,以便我可以进行以下更改:

 schema.config().option('graph.schema_mode').set('Development') schema.vertexLabel('test').create() 

如何创建一个不存在代码的图表? 我试图搜索java-dse-graph驱动程序代码,但我没有找到任何东西:/

谢谢!

请注意,您可以使用SimpleGraphStatement设置图形选项,如文档所示: http ://docs.datastax.com/en/developer/java-driver-dse/1.1/manual/graph/#graph-options