{"__v":0,"_id":"5879070da49d223700dacb39","category":{"__v":0,"_id":"57d6ada046dcc30e007dd15e","project":"566c97797831040d003eb3bc","version":"566c97797831040d003eb3bf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-09-12T13:29:04.136Z","from_sync":false,"order":8,"slug":"drivers-and-languages","title":"Language center"},"parentDoc":null,"project":"566c97797831040d003eb3bc","user":"5716283e40ef9c2000cac92a","version":{"__v":10,"_id":"566c97797831040d003eb3bf","project":"566c97797831040d003eb3bc","createdAt":"2015-12-12T21:54:01.970Z","releaseDate":"2015-12-12T21:54:01.970Z","categories":["566c977a7831040d003eb3c0","5716338cb5af590e00a0ff1d","57163947893cbe0e002d75fc","57163f41b5af590e00a0ff35","57cd74d2873de50e00724a2f","57cd7de8baaee30e0093ecc3","57d6ada046dcc30e007dd15e","57fdc2b31646dc0e0010480a","57fdd8b86c9d141900d87bf1","58767da4d89ef20f003b6f1e"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-13T16:57:49.839Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"If Java is your language of choice, the most popular drivers for Neo4j are:\n\n* [Neo4j Java driver](#section-neo4j-bolt-driver-for-java) [official driver]\n* [Neo4j OGM](#section-neo4j-ogm) [community driver]\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"About connection parameters\",\n  \"body\": \"We've used test credentials for all the following examples. Please replace them with your real connection parameters.\\n\\nYou'll find all the required information to connect to your database on our admin panel if you navigate to the Connection section. More on connecting to your database [here](doc:connecting-to-your-database)\"\n}\n[/block]\n## Neo4j Bolt driver for Java\n\nNeo4j Java Driver is the official Neo4j Java driver for connecting to Neo4j databases via Bolt (HTTP/HTTPS not available).\n\nDriver web page: https://github.com/neo4j/neo4j-java-driver \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"**Bolt protocol is only available in 3.0.0 or higher versions of Neo4j.** You can check your Neo4j version if you navigate to the Overview page of your database.\"\n}\n[/block]\nThe following example is a Maven application that just uses the driver to write and read a node. \n\nInclude Neo4j Java Driver in your dependencies in pom.xml file:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<dependencies>\\n    <dependency>\\n        <groupId>org.neo4j.driver</groupId>\\n        <artifactId>neo4j-java-driver</artifactId>\\n        <version>1.0.4</version>\\n    </dependency>\\n</dependencies>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Check the [driver releases](https://github.com/neo4j/neo4j-java-driver/releases) for newest driver version available.\"\n}\n[/block]\nConnect to the to a GrapheneDB instance using the connection settings and create a dummy node:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import org.neo4j.driver.v1.*;\\n\\npublic class App \\n{\\n  public static void main( String[] args )\\n  {\\n    Driver driver = GraphDatabase.driver( \\\"bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786\\\", AuthTokens.basic( \\\"v303\\\", \\\"GtGq5rldxu\\\" ) );\\n\\n    Session session = driver.session();\\n\\n    session.run(\\\"CREATE (n:Person {name:'Bob'})\\\");\\n    StatementResult result = session.run(\\\"MATCH (n:Person) RETURN n.name AS name\\\");\\n\\n    while ( result.hasNext() )\\n    {\\n      Record record = result.next();\\n      System.out.println( record.get(\\\"name\\\").asString() );\\n    }\\n\\n    session.close();\\n    driver.close();\\n  }\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n## Neo4j OGM\n\nNeo4j OGM is a library that allows you to use Object Graph Mapping from any Java or JVM-based application without requiring additional dependencies. It's also optimized for server-based installations utilizing Cypher via the transactional HTTP endpoint.\n\nNeo4j OGM version 2.0.2 and higher also support the Bolt protocol.\n\nDriver documentation page: https://github.com/neo4j/neo4j-ogm\n\nNeo4j OGM projects can be built using Maven, Gradle or Ant/Ivy. You will find information for the other build tools in the [driver manual](https://neo4j.com/docs/ogm-manual/current/reference/#reference-setup). The following configuration is for a Maven application. \n\nYou will need to include dependencies entries for neo4j-ogm-core and the drivers you want to use in pom.xml file.  If you’re not using a particular driver, you don’t need to declare it.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<dependency>\\n    <groupId>org.neo4j</groupId>\\n    <artifactId>neo4j-ogm-core</artifactId>\\n    <version>2.0</version>\\n</dependency>\\n\\n<dependency>\\n    <groupId>org.neo4j</groupId>\\n    <artifactId>neo4j-ogm-http-driver</artifactId>\\n    <version>2.0</version>\\n</dependency>\\n\\n<dependency>\\n    <groupId>org.neo4j</groupId>\\n    <artifactId>neo4j-ogm-bolt-driver</artifactId>\\n    <version>2.0</version>\\n</dependency>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n**Please note:** If you are using Neo4j OGM 1.x, you only need to add the following dependency (Bolt protocol support is not available for this version):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<dependency>\\n    <groupId>org.neo4j</groupId>\\n    <artifactId>neo4j-ogm</artifactId>\\n    <version>2.0</version>\\n</dependency>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Check the [driver releases](https://github.com/neo4j/neo4j-ogm/blob/master/CHANGES.txt) for newest driver version available.\"\n}\n[/block]\nFirst, you will need to set up the domain entities of your application. See the [driver documentation](https://github.com/neo4j/neo4j-ogm#set-up-domain-entities) for more info.\n\nThen you will need connect to the to a GrapheneDB instance. There are two basic ways to supply configuration information to OGM Neo4j: via a single properties file, or programmatically. Read more in [this driver documentation section](https://neo4j.com/docs/ogm-manual/current/reference/#reference-ogm2x-configuration).\n\n### Using the properties file (ogm.properties). This file must be on the classpath.\n\nWith HTTP driver:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"driver=org.neo4j.ogm.drivers.http.driver.HttpDriver\\nURI=http://hobby-geefdaeefcom.dbs.graphenedb.com:24789\\nusername=v303\\npassword=GtGq5rldxu\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nWith Bolt driver:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"driver=org.neo4j.ogm.drivers.bolt.driver.BoltDriver\\nURI=hobby-geefdaeefcom.dbs.graphenedb.com:24786\\nusername=v303\\npassword=GtGq5rldxu\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nCreate a new session:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SessionFactory sessionFactory = new SessionFactory();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n### Using Java Configuration.\n\nWith HTTP driver:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Configuration configuration = new Configuration();\\nconfiguration.driverConfiguration()\\n  .setDriverClassName(\\\"org.neo4j.ogm.drivers.http.driver.HttpDriver\\\")\\n  .setURI(\\\"http://hobby-geefdaeefcom.dbs.graphenedb.com:24789\\\")\\n  .setCredentials(\\\"v303\\\", \\\"GtGq5rldxu\\\");\\n\\n// We pass it as the first argument to a SessionFactory instance\\nnew SessionFactory(configuration, ...);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nWith Bolt driver:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Configuration configuration = new Configuration();\\nconfiguration.driverConfiguration()\\n  .setDriverClassName(\\\"org.neo4j.ogm.drivers.bolt.driver.BoltDriver\\\")\\n  .setURI(\\\"bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786\\\")\\n  .setCredentials(\\\"v303\\\", \\\"GtGq5rldxu\\\");\\n\\n// We pass it as the first argument to a SessionFactory instance\\nnew SessionFactory(configuration, ...);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nIf you are using Neo4j OGM 1.x, simply pass the HTTP connection URL to the session object:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SessionFactory sessionFactory = new SessionFactory(\\\"org.neo4j.example.domain\\\");\\nSession session = sessionFactory.openSession(\\\"http://v303:GtGq5rldxu:::at:::hobby-geefdaeefcom.dbs.graphenedb.com:24789\\\");\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"java","type":"basic","title":"Java"}
If Java is your language of choice, the most popular drivers for Neo4j are: * [Neo4j Java driver](#section-neo4j-bolt-driver-for-java) [official driver] * [Neo4j OGM](#section-neo4j-ogm) [community driver] [block:callout] { "type": "info", "title": "About connection parameters", "body": "We've used test credentials for all the following examples. Please replace them with your real connection parameters.\n\nYou'll find all the required information to connect to your database on our admin panel if you navigate to the Connection section. More on connecting to your database [here](doc:connecting-to-your-database)" } [/block] ## Neo4j Bolt driver for Java Neo4j Java Driver is the official Neo4j Java driver for connecting to Neo4j databases via Bolt (HTTP/HTTPS not available). Driver web page: https://github.com/neo4j/neo4j-java-driver [block:callout] { "type": "info", "body": "**Bolt protocol is only available in 3.0.0 or higher versions of Neo4j.** You can check your Neo4j version if you navigate to the Overview page of your database." } [/block] The following example is a Maven application that just uses the driver to write and read a node. Include Neo4j Java Driver in your dependencies in pom.xml file: [block:code] { "codes": [ { "code": "<dependencies>\n <dependency>\n <groupId>org.neo4j.driver</groupId>\n <artifactId>neo4j-java-driver</artifactId>\n <version>1.0.4</version>\n </dependency>\n</dependencies>", "language": "xml" } ] } [/block] [block:callout] { "type": "info", "body": "Check the [driver releases](https://github.com/neo4j/neo4j-java-driver/releases) for newest driver version available." } [/block] Connect to the to a GrapheneDB instance using the connection settings and create a dummy node: [block:code] { "codes": [ { "code": "import org.neo4j.driver.v1.*;\n\npublic class App \n{\n public static void main( String[] args )\n {\n Driver driver = GraphDatabase.driver( \"bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786\", AuthTokens.basic( \"v303\", \"GtGq5rldxu\" ) );\n\n Session session = driver.session();\n\n session.run(\"CREATE (n:Person {name:'Bob'})\");\n StatementResult result = session.run(\"MATCH (n:Person) RETURN n.name AS name\");\n\n while ( result.hasNext() )\n {\n Record record = result.next();\n System.out.println( record.get(\"name\").asString() );\n }\n\n session.close();\n driver.close();\n }\n}", "language": "java" } ] } [/block] ## Neo4j OGM Neo4j OGM is a library that allows you to use Object Graph Mapping from any Java or JVM-based application without requiring additional dependencies. It's also optimized for server-based installations utilizing Cypher via the transactional HTTP endpoint. Neo4j OGM version 2.0.2 and higher also support the Bolt protocol. Driver documentation page: https://github.com/neo4j/neo4j-ogm Neo4j OGM projects can be built using Maven, Gradle or Ant/Ivy. You will find information for the other build tools in the [driver manual](https://neo4j.com/docs/ogm-manual/current/reference/#reference-setup). The following configuration is for a Maven application. You will need to include dependencies entries for neo4j-ogm-core and the drivers you want to use in pom.xml file. If you’re not using a particular driver, you don’t need to declare it. [block:code] { "codes": [ { "code": "<dependency>\n <groupId>org.neo4j</groupId>\n <artifactId>neo4j-ogm-core</artifactId>\n <version>2.0</version>\n</dependency>\n\n<dependency>\n <groupId>org.neo4j</groupId>\n <artifactId>neo4j-ogm-http-driver</artifactId>\n <version>2.0</version>\n</dependency>\n\n<dependency>\n <groupId>org.neo4j</groupId>\n <artifactId>neo4j-ogm-bolt-driver</artifactId>\n <version>2.0</version>\n</dependency>", "language": "xml" } ] } [/block] **Please note:** If you are using Neo4j OGM 1.x, you only need to add the following dependency (Bolt protocol support is not available for this version): [block:code] { "codes": [ { "code": "<dependency>\n <groupId>org.neo4j</groupId>\n <artifactId>neo4j-ogm</artifactId>\n <version>2.0</version>\n</dependency>", "language": "xml" } ] } [/block] [block:callout] { "type": "info", "body": "Check the [driver releases](https://github.com/neo4j/neo4j-ogm/blob/master/CHANGES.txt) for newest driver version available." } [/block] First, you will need to set up the domain entities of your application. See the [driver documentation](https://github.com/neo4j/neo4j-ogm#set-up-domain-entities) for more info. Then you will need connect to the to a GrapheneDB instance. There are two basic ways to supply configuration information to OGM Neo4j: via a single properties file, or programmatically. Read more in [this driver documentation section](https://neo4j.com/docs/ogm-manual/current/reference/#reference-ogm2x-configuration). ### Using the properties file (ogm.properties). This file must be on the classpath. With HTTP driver: [block:code] { "codes": [ { "code": "driver=org.neo4j.ogm.drivers.http.driver.HttpDriver\nURI=http://hobby-geefdaeefcom.dbs.graphenedb.com:24789\nusername=v303\npassword=GtGq5rldxu", "language": "java" } ] } [/block] With Bolt driver: [block:code] { "codes": [ { "code": "driver=org.neo4j.ogm.drivers.bolt.driver.BoltDriver\nURI=hobby-geefdaeefcom.dbs.graphenedb.com:24786\nusername=v303\npassword=GtGq5rldxu", "language": "java" } ] } [/block] Create a new session: [block:code] { "codes": [ { "code": "SessionFactory sessionFactory = new SessionFactory();", "language": "java" } ] } [/block] ### Using Java Configuration. With HTTP driver: [block:code] { "codes": [ { "code": "Configuration configuration = new Configuration();\nconfiguration.driverConfiguration()\n .setDriverClassName(\"org.neo4j.ogm.drivers.http.driver.HttpDriver\")\n .setURI(\"http://hobby-geefdaeefcom.dbs.graphenedb.com:24789\")\n .setCredentials(\"v303\", \"GtGq5rldxu\");\n\n// We pass it as the first argument to a SessionFactory instance\nnew SessionFactory(configuration, ...);", "language": "java" } ] } [/block] With Bolt driver: [block:code] { "codes": [ { "code": "Configuration configuration = new Configuration();\nconfiguration.driverConfiguration()\n .setDriverClassName(\"org.neo4j.ogm.drivers.bolt.driver.BoltDriver\")\n .setURI(\"bolt://hobby-geefdaeefcom.dbs.graphenedb.com:24786\")\n .setCredentials(\"v303\", \"GtGq5rldxu\");\n\n// We pass it as the first argument to a SessionFactory instance\nnew SessionFactory(configuration, ...);", "language": "java" } ] } [/block] If you are using Neo4j OGM 1.x, simply pass the HTTP connection URL to the session object: [block:code] { "codes": [ { "code": "SessionFactory sessionFactory = new SessionFactory(\"org.neo4j.example.domain\");\nSession session = sessionFactory.openSession(\"http://v303:GtGq5rldxu@hobby-geefdaeefcom.dbs.graphenedb.com:24789\");", "language": "java" } ] } [/block]