以下代碼片段嘗試連接到Graph並對其執行一些操作。它旨在使用Graph的DSE Java驅動程序1.1運行。來自Java的DSE圖形 - 無法訪問DelegatingCluster
import com.datastax.driver.dse.graph.GraphStatement;
import com.datastax.driver.dse.graph.SimpleGraphStatement;
import com.datastax.driver.dse.DseCluster;
import com.datastax.driver.dse.DseSession;
public class GraphTest {
public static void main(String[] args) {
System.out.println("Start...");
DseCluster dseCluster = DseCluster.builder()
.addContactPoint("127.0.0.1")
.build();
DseSession dseSession = dseCluster.connect();dseSession.executeGraph("system.graph('demo').ifNotExists().create()");
GraphStatement s1 = new SimpleGraphStatement("g.addV(label, 'test_vertex')").setGraphName("demo");
dseSession.executeGraph(s1);
GraphStatement s2 = new SimpleGraphStatement("g.V()").setGraphName("demo");
GraphResultSet rs = dseSession.executeGraph(s2);
System.out.println(rs.one().asVertex());
System.out.println("End.");
}
}
然而,編譯提供了以下錯誤:
javac -cp .\dse-driver-1.1.0.jar GraphTest.java
GraphTest.java:12: error: cannot access DelegatingCluster DseCluster dseCluster = DseCluster.builder() ^ class file for com.datastax.driver.core.DelegatingCluster not found GraphTest.java:16: error: cannot access Session DseSession dseSession = dseCluster.connect();dseSession.executeGraph("system.graph('demo').ifNotExists().create()"); ^ class file for com.datastax.driver.core.Session not found GraphTest.java:22: error: cannot find symbol GraphResultSet rs = dseSession.executeGraph(s2); ^ symbol: class GraphResultSet location: class GraphTest 3 errors
它看起來像訪問類建立會話不對勁。這裏有什麼遺漏嗎?