1

我试图通过 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 驱动程序代码,但没有找到任何东西:/

谢谢!

4

1 回答 1

1

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

于 2016-12-20T20:54:26.630 回答