gistfile1.txt import java.sql.DriverManager;import java.sql.Connection;public class AgensGraphTest { public static void main(String[] args) { Class.forName("net.bitnine.agensgraph.Driver"); String connectionString = "jdbc:agensgraph://127.0
import java.sql.DriverManager; import java.sql.Connection; public class AgensGraphTest { public static void main(String[] args) { Class.forName("net.bitnine.agensgraph.Driver"); String connectionString = "jdbc:agensgraph://127.0.0.1:5432/agens"; String username = "test"; String password = "test"; Connection conn = DriverManager.getConnection(connectionString, username, password); //创建对象 PreparedStatement pstmt = con.prepareStatement("CREATE (:Person ?)"); JsonObject john = new JsonObject(); john.put("name", "John"); john.put("from", "USA"); john.put("age", 17); pstmt.setObject(1, john); pstmt.execute(); //查询 Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( "MATCH (:Person {name: 'John'})-[:knows]-(friend:Person)" + "RETURN friend"); while (rs.next()) { Vertex friend = (Vertex)rs.getObject(1); System.out.println(friend.getProperty().getString("name")); System.out.println(friend.getProperty().getInt("age")); } } }