Neo4j Java REST Binding vs Neo4j JDBC Driver

1,611 views
Skip to first unread message

BtySgtMajor

unread,
Apr 1, 2014, 6:09:00 PM4/1/14
to ne...@googlegroups.com
Hi all,

  Given that both the Java REST binding and the JDBC drivers are available (both of which can communicate w/ a Neo4j server via REST), besides the usage/familiarity with them, what are the real differences/pros/cons between the two, if any at all?  I've been going through both and am curious.

  Michael Hunger, maybe you could weigh in?

Cheers,
Duncan

Jacob Hansson

unread,
Apr 1, 2014, 6:49:05 PM4/1/14
to ne...@googlegroups.com
Duncan, the neo4j-rest-binding was built before Cypher was invented, and before the transactional endpoint was introduced. As such, it generally uses the CRUD operations exposed by Neo4js REST API, and it implements the Core Java API which the original Neo4j Embedded did (and still does). Unfortunatly, while the embedded API is very fast when run in-process, it is not a very  suitable API to use over the network. The REST API also does not expose long-running transactions.

As such, the JDBC API was built, and uses Cypher only and (in the latest version) the new transactional endpoint. This means that for every network hop incurred, it performs much more work by virtue of sending a full Cypher query rather than a REST CRUD call. It also means it's generally faster, because the transactional endpoint is faster, and it means it allows keeping a running transaction and reading intermediary results.

Eg. if you are starting a new project in Java, I would recommend JDBC. That said, it's not an official Neo4j component, it's a community managed project.

/jake


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

BtySgtMajor

unread,
Apr 1, 2014, 6:53:26 PM4/1/14
to ne...@googlegroups.com
Thanks for the detailed answer, Jake!

That answers more or less what I was thinking.  I was also curious as I believe SDN uses the Java REST binding, does it not?  Or has it, too, moved to using the JDBC driver (or another REST wrapper) when dealing with Neo4j non-embedded instances?

Michael Hunger

unread,
Apr 1, 2014, 7:07:42 PM4/1/14
to ne...@googlegroups.com
JDBC is cypher over the wire and towards embedded databases.

Java-Rest-Binding mimics the embedded core-api over the wire with many fine grained calls to REST-Endpoints but also supports some old-style cypher + remote traversals.

I prefer to use JDBC w/ Cypher these days for remote interaction.


On Wed, Apr 2, 2014 at 12:09 AM, BtySgtMajor <btysg...@gmail.com> wrote:

--

Michael Hunger

unread,
Apr 1, 2014, 7:15:14 PM4/1/14
to ne...@googlegroups.com
SDN can't yet, as it was also created before the introduction of cypher and so would need a full internal rewrite to use cypher instead of the core API do to the object graph mapping operations.

And as I don't have enough spare time for a one or two-month rewrite, it didn't change yet.

Rickard Öberg

unread,
Apr 1, 2014, 10:38:21 PM4/1/14
to ne...@googlegroups.com
On 4/2/14, 07:07 , Michael Hunger wrote:
> JDBC is cypher over the wire and towards embedded databases.
>
> Java-Rest-Binding mimics the embedded core-api over the wire with many
> fine grained calls to REST-Endpoints but also supports some old-style
> cypher + remote traversals.
>
> I prefer to use JDBC w/ Cypher these days for remote interaction.

Hi!

I wrote the JDBC driver initially as a proof of concept, and Michael has
touched it up to support streaming and whatnot. But both of us did so in
our spare time, and it's not an officially supported driver (yet).

I recently used the driver myself for an internal Neo Tech app, and I
found it very useful to be able to use the same driver in code during
testing (using CommunityServerBuilder to run a Neo instance), running
the app locally (with an in-mem database), and in production (with a
separate Neo4j Server instance). The JDBC API shielded me from these
differences, and the main difference is latency of calls.

There are a few gotchas I found (such as "RETURN node" returning a Node
object with embedded and a Map<String, Object> when used with REST API),
and there are still more cleanups me and MH want to do. But again, this
is so far all in our spare time.

regards, Rickard

--
Rickard Öberg
Developer
Neo Technology
Twitter: @rickardoberg, Skype: rickardoberg

typwr...@gmail.com

unread,
Aug 15, 2014, 9:17:38 AM8/15/14
to ne...@googlegroups.com
Hello all,

I am fairly new to programming, although I understand the basic concepts, so not everything may make sense.

First of all thanks for the great work!

Is there a rough time schedule when the neo4j JDBC driver could be updated to the latest developments and useable for production? I am mostly thinking about using labels instead of relationships and such. This way it should be possible to use all sorts of existing frameworks that are developed for relational databases, which would be good fun :)
If developed carefully a relational database can be converted to graphs. This is not the best solution because of possible performance issues, but will allow the possibility to migrate to a new structure while still being operational. The extra relationships to the elements can be added that are needed for the new structure. It would be the first migration of a live database!

Sukaant Chaudhary

unread,
Aug 16, 2014, 11:20:25 AM8/16/14
to ne...@googlegroups.com
Hi All,
Can we use any framework for this?

-Sukaant Chaudhary



--

Michael Hunger

unread,
Aug 16, 2014, 12:44:30 PM8/16/14
to ne...@googlegroups.com
The jdbc driver can already be used even in prod.

If you use it with neo4j server the protocoll is fairly stable and doesn't have to be updated for each neo4j version

Sent from mobile device
--

Roopa ML

unread,
Dec 22, 2015, 5:52:48 PM12/22/15
to Neo4j
We are using Java 6.
What version of neo4j-jdbc is compatible with this?

Michael Hunger

unread,
Dec 25, 2015, 7:35:17 PM12/25/15
to ne...@googlegroups.com
Good question.

Afaik there is no compatible version with java6, we switched to Java7 for neo4j-jdbc with neo4j's upgrade to java7.

So you might be best of using plain REST using Jersey in Java6.

Michael

Roopa ML

unread,
Jan 4, 2016, 12:48:08 PM1/4/16
to Neo4j
Thanks for the quick response. I will explore using REST
Reply all
Reply to author
Forward
0 new messages