# Bolt client TuGraph implements Neo4j's bolt protocol, you can use Neo4j's client to access TuGraph. ## Enable bolt port The Bolt port is enabled by default on port 7687. If you need to change the port, you can do so in the configuration file. For services deployed using the Docker method, the configuration file is located within the container at `/usr/local/etc/lgraph.json`; for services deployed using the RPM package, the configuration file is on the server at `/usr/local/etc/lgraph.json`. To apply the port change, you will need to restart the service. Specific instructions for restarting the service can be found in [Tugraph Running](../../5.installation&running/7.tugraph-running.md). Additionally, for a detailed explanation of the configuration options available in the configuration file, see the "Configuration parameters" section in [Tugraph Running](../../5.installation&running/7.tugraph-running.md). ## Use case example Add Maven dependency ```xml org.neo4j.driver neo4j-java-driver 4.4.2 ``` Instantiate the client as follows: ```java Driver driver = GraphDatabase.driver("bolt://ip:port", AuthTokens.basic("admin", "73@TuGraph")); ``` Common statements: ```java //Create a session through the driver object, setting the session to connect to a specific database, to execute Cypher statements. Session session = driver.session(SessionConfig.forDatabase("default")); //Clear the graph project, please do not attempt this lightly as it will delete both the schema and data of the selected graph project. session.run("CALL db.dropDB()"); //Create vertex session.run("CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)"); //Create edge session.run("CALL db.createEdgeLabel('is_friend','[[\"person\",\"person\"]]')"); //Create index session.run("CALL db.addIndex(\"person\", \"name\", false)"); //Insert vertex data session.run("create (n1:person {name:'jack',id:1}), (n2:person {name:'lucy',id:2})"); //Insert edge data session.run("match (n1:person {id:1}), (n2:person {id:2}) create (n1)-[r:is_friend]->(n2)"); //Query vertices and edges Result res = session.run("match (n)-[r]->(m) return n,r,m"); //Parameterized Query String cypherQuery = "MATCH (n1:person {id:$id})-[r]-(n2:person {name:$name}) RETURN n1, r, n2"; Result result1 = session.run(cypherQuery, parameters("id", 1, "name", "lucy")); while (result1.hasNext()) { Record record = result1.next(); System.out.println("n1: " + record.get("n1").asMap()); System.out.println("r: " + record.get("r").asMap()); System.out.println("n2: " + record.get("n2").asMap()); } //Delete vertex data session.run("match (n1:person {id:1}) delete n1"); //Delete edge data session.run("match (n1:person {id:1})-[r]-(n2:person{id:2}) delete r"); //Delete edge session.run("CALL db.deleteLabel('edge', 'is_friend')"); //Delete vertex session.run("CALL db.deleteLabel('vertex', 'person')"); ``` Details on the use of Cypher and stored procedures can be found in [Cypher](../../8.query/1.cypher.md) ## Limitations on use Currently, our system does not fully support all advanced features of the Neo4j Bolt protocol. In particular, immediate transaction processing and flexible weak schema, two unique capabilities of the Neo4j client, are not yet supported. Therefore, when using the client, please make sure to avoid operations that involve these features to ensure smooth running of the application and consistency of data. ## Example of Client Usage In the code directory under demo/Bolt, there are examples in Golang, JavaScript, Java, JavaScript, Python, and Rust. To learn more, see [Example of Client Usage](https://github.com/TuGraph-family/tugraph-db/tree/master/demo)