why cannot i use this way to create node use int array
int[] newnode=new int[10];
for(int i=0; i<newnode.length; i++){
Node newnode[i]=db.createNode();
}
newnode[1].createRelationshipTo(newnode[2], Rels.KNOWS );
On Thursday, April 17, 2014 3:56:44 AM UTC-7, Anders Nawroth wrote:
>
> Hi!
>
> Did you initialize the db field?
>
> Something like
> db = new GraphDatabaseFactory().newEmbeddedDatabase( "path/to/db" );
>
> /anders
>
>
> On Thu, Apr 17, 2014 at 9:11 AM, Tingting Cui <[email protected]<javascript:>
> > wrote:
>
>> when i try to run TraversalExample.java example and create the graph like
>> this
>> it give me error like this
>> Exception in thread "main" java.lang.NullPointerException
>> at setupneo4j.TraversalExample.<init>(TraversalExample.java:23)
>> at setupneo4j.TraversalExample.main(TraversalExample.java:33)
>> what is the problems here.
>> public static void main( String[] args )
>> {
>>
>> TraversalExample op = new TraversalExample( db );
>> op.shutdownGraph();
>> }
>> public void shutdownGraph()
>> {
>> try
>> {
>> if ( db != null )
>> {
>> db.shutdown();
>> }
>> }
>> finally
>> {
>> db = null;
>> }
>> }
>>
>> public Node createTheGraph()
>> {
>> try ( Transaction tx = db.beginTx() )
>> {
>> // START SNIPPET: createGraph
>> Node A = db.createNode();
>> Node B = db.createNode();
>> Node C = db.createNode();
>> Node D = db.createNode();
>>
>> A.createRelationshipTo( C, Rels.KNOWS );
>> C.createRelationshipTo( D, Rels.KNOWS );
>> A.createRelationshipTo( B, Rels.KNOWS);
>> B.createRelationshipTo( C, Rels.KNOWS );
>> // END SNIPPET: createGraph
>> A.setProperty( "name", "A" );
>> B.setProperty( "name", "B" );
>> C.setProperty( "name", "C" );
>> D.setProperty( "name", "D" );
>> tx.success();
>> return A;
>> }
>> }
>>
>> --
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Anders Nawroth [[email protected] <javascript:>]
> Skype: anders.nawroth
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.