I was trying to create my first connection with DSE Graph through java..
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();
}
}
At first I was getting that "graph" doesn't exist.. I had to create a connection to the specific graph through DataStax Studio since it wasn't there..
Now I need to put the labels,properties etc in the schema.. I know how to do it in the studio (https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/using/createSchemaStudio.html) but I would like to do it in the code instead. How can I have access to the schema object in Java so I can make changes like those:
schema.config().option('graph.schema_mode').set('Development')
schema.vertexLabel('test').create()
also how is it possible to create a graph that doesn't exist through code? I tried to search through the java-dse-graph driver code but I didn't find anything :/
Thanks!
Note that you can set graph options with a SimpleGraphStatement, as the docs show: http://docs.datastax.com/en/developer/java-driver-dse/1.1/manual/graph/#graph-options