Get existing database from web application in java

55 views
Skip to first unread message

Samwillie

unread,
May 7, 2012, 6:38:44 AM5/7/12
to Neo4j
Hi experts,

I have with your help here, created a database (populated with nodes,
relationships, indexing them both) and installed on a remote server. I
can see all details in the web-admin interface now of my remote neo4j
server.

For each node, I have set a manual ID, so am not using the Neo4j node
id. Now, I need a restful web application that does cypher queries on
the database and gets me information from the database.

Now to access this database from my web application (Java, spring mvc
rest, glassfish). Is there a method?

Creating a new database can be done by for example, graphDbService =
new EmbeddedGraphDatabase(localpath); or new RestGraphDatabase(url)
methods. Is there something similar to get an existing database, so I
can use it for querying can retrieving information from my
application?

Thanks,

Peter Neubauer

unread,
May 7, 2012, 6:49:12 AM5/7/12
to ne...@googlegroups.com
Hi there,
if you start up the Neo4j server against your existing database (by
configuring the database path in conf/neo4j-server.properties), you
should be able to see the data. then, doing new RestGraphDatabase(url)
against that server will give you access to the DB from your Java
application.


Then, you can just execute queries against the database like

start sNode = node:myIds(id='xyz') match sNode-[r]-() return sNode,
sNode.myID, r

to return a node with your custom ID and its relationships. You will
have to index the nodes with your custom ID in order to make them
searchable of course.

Does that make sense?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

Samwillie

unread,
May 7, 2012, 8:40:27 AM5/7/12
to Neo4j
Hi Peter,

Thank you very much! And the query was really helpful.:)

Greets,

On May 7, 12:49 pm, Peter Neubauer <peter.neuba...@neotechnology.com>
wrote:
Reply all
Reply to author
Forward
0 new messages