Book Image

Neo4j Cookbook

By : Ankur goel, Ankur Goel
Book Image

Neo4j Cookbook

By: Ankur goel, Ankur Goel

Overview of this book

Table of Contents (17 chapters)
Neo4j Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing Neo4j from Scala


Scala is a general purpose language, which is being increasingly used for high-performance applications, as it has been implemented over JVM, which makes interoperability easier with the existing Java libraries.

In this recipe, we will learn how to access the Neo4j graph database using Scala.

How to do it...

There are multiple solutions for this problem, although there is no standard module that can be considered as the de facto standard with Scala. The solution is listed in the following steps:

  1. Java JAR files works with Scala due to interoperability, so the first way is to import Neo4j JAR files, which can be found under the lib directory, under the Scala project.

  2. There are many REST clients available in Scala, such as Lift, Scalatra, and Akka with Spray, so it is easy to write your own code on the top of any of these libraries. One such example is being shown here:

    import dispatch._
    val http_client = new Http
    val json = http_client(:/("localhost:7474/data/db/) /  ...