Hi Michael,

Thank you for the quick response. It is working now as expected. :)

On Thursday, September 4, 2014 3:44:38 PM UTC-4, Michael Hunger wrote:
>
> You have the wrong execution-engine, you need the javacompat one.
>
> Your results contain nodes to access them (for printing) you need a 
> transaction.
> There is a result.dumpToString() method which you can use within your 
> transaction.
>
> Or just return attributes of the nodes from your query.
>
> Michael
>
> Am 04.09.2014 um 21:37 schrieb [email protected] <javascript:>:
>
> Hi Sukaant,
>
> I tried integrating my database with Java. I created a small java 
> application, added neo4j dependency in pom.xml.
>
> Below is the code I wrote.
>
> GraphDatabaseService db = new 
> GraphDatabaseFactory().newEmbeddedDatabase("path of my db");
> ExecutionEngine engine = new ExecutionEngine(db, StringLogger.SYSTEM );
>
> ExecutionResult result;
> try ( Transaction ignored = db.beginTx() )
> {
>     result = engine.execute( "match (n) return n" );
> }
>  System.out.print(result);
> db.shutdown();
>
> This is throwing the below error. I tried looking for the solution, but 
> that was not successful. Below is the error i received.
>
> Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: 
> Failed to mark transaction as rollback only.
> at 
> org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:97)
> at 
> org.neo4j.kernel.TopLevelTransaction.failure(TopLevelTransaction.java:86)
> at 
> org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext.close(TransactionBoundQueryContext.scala:65)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.close(DelegatingQueryContext.scala:38)
> at org.neo4j.cypher.internal.compiler.v2_1.
> spi.ExceptionTranslatingQueryContext.org 
> <http://spi.exceptiontranslatingquerycontext.org/>
> $neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$super$close(ExceptionTranslatingQueryContext.scala:34)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply$mcV$sp(ExceptionTranslatingQueryContext.scala:34)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply(ExceptionTranslatingQueryContext.scala:34)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply(ExceptionTranslatingQueryContext.scala:34)
> at org.neo4j.cypher.internal.compiler.v2_1.
> spi.ExceptionTranslatingQueryContext.org 
> <http://spi.exceptiontranslatingquerycontext.org/>
> $neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:152)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.close(ExceptionTranslatingQueryContext.scala:34)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.close(DelegatingQueryContext.scala:38)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder$$anonfun$runWithQueryState$1.apply(ExecutionPlanBuilder.scala:164)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder$$anonfun$runWithQueryState$1.apply(ExecutionPlanBuilder.scala:164)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.TaskCloser$$anonfun$1.apply(TaskCloser.scala:43)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.TaskCloser$$anonfun$1.apply(TaskCloser.scala:41)
> at 
> scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
> at 
> scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
> at scala.collection.immutable.List.foreach(List.scala:318)
> at 
> scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
> at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.TaskCloser.close(TaskCloser.scala:40)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply$mcV$sp(ClosingIterator.scala:67)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply(ClosingIterator.scala:67)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply(ClosingIterator.scala:67)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$translateException$1.apply(ClosingIterator.scala:72)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.translateException(ClosingIterator.scala:70)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.close(ClosingIterator.scala:66)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$failIfThrows$1.apply(ClosingIterator.scala:96)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.failIfThrows(ClosingIterator.scala:91)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.hasNext(ClosingIterator.scala:34)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult.hasNext(PipeExecutionResult.scala:167)
> at scala.collection.Iterator$class.toString(Iterator.scala:1153)
> at 
> org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult.toString(PipeExecutionResult.scala:35)
> at java.lang.String.valueOf(String.java:2854)
> at java.io.PrintStream.print(PrintStream.java:683)
> at cricketFun.main(cricketFun.java:25)
> Caused by: java.lang.NullPointerException
> at 
> org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:93)
> ... 37 more
>
>
> Why is it failing to fetch the data? Am I doing anything wrong? Also, if I 
> tried running the application second time, it throws me this error.
>
>
> Exception in thread "main" java.lang.RuntimeException: Error starting 
> org.neo4j.kernel.EmbeddedGraphDatabase, 
> C:\Users\sd482\Documents\Neo4j\default.graphdb
> at 
> org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:362)
> at 
> org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)
> at 
> org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:90)
> at 
> org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:199)
> at 
> org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:70)
> at cricketFun.main(cricketFun.java:16)
> Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 
> 'org.neo4j.kernel.StoreLockerLifecycleAdapter@f1bb79c' was successfully 
> initialized, but failed to start. Please see attached cause exception.
> at 
> org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
> at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
> at 
> org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:339)
> ... 5 more
> Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on 
> store lock file: C:\Users\sd482\Documents\Neo4j\default.graphdb\store_lock. 
> Please ensure no other process is using this database, and that the 
> directory is writable (required even for read-only access)
> at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:82)
> at 
> org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:44)
> at 
> org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
> ... 7 more
> Caused by: java.io.IOException: Couldn't lock lock file 
> C:\Users\sd482\Documents\Neo4j\default.graphdb\lock because another process 
> already holds the lock.
> at 
> org.neo4j.kernel.impl.nioneo.store.FileLock.getLockFileBasedFileLock(FileLock.java:120)
> at 
> org.neo4j.kernel.impl.nioneo.store.FileLock.getOsSpecificFileLock(FileLock.java:64)
> at 
> org.neo4j.kernel.DefaultFileSystemAbstraction.tryLock(DefaultFileSystemAbstraction.java:93)
> at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
> ... 9 more
>
>
> I know this is due to the locking issue. Though I'm using "db.shutdown();" 
> in my code, it is not unlocking the database when the application is 
> terminated. I had to close the IDE everytime to unlock it. Please let me 
> know where I am making the mistake.
>
> Sorry for the very long question, and thank you so much for your help. :)
>
> Thanks,
> Shashank
>
>
>
> On Thursday, September 4, 2014 5:17:22 AM UTC-4, Sukaant Chaudhary wrote:
>>
>> Hi Shashank,
>> Use the code in the following link, it is cypher-jdbc, it will help you 
>> to integrate with Java:
>> http://docs.neo4j.org/chunked/stable/tutorials-cypher-java.html
>>
>> You need the following dependency:
>> <dependency>
>>           <groupId>org.neo4j</groupId>
>>           <artifactId>neo4j-kernel</artifactId>
>>           <version>${neo4j.version}</version>
>>  </dependency>
>>
>> About Tomcat and Maven
>> Tomcat is a Server whereas Maven is a build tool both are different 
>> things.
>>
>> Hope this will help.
>> If you have any further queries please feel free to ask.
>>
>> -Sukaant Chaudhary
>> <http://in.linkedin.com/pub/sukaant-chaudhary/33/ba8/479>
>>
>>
>> On Thu, Sep 4, 2014 at 7:22 AM, <[email protected]> wrote:
>>
>>> Hello,
>>>
>>> My name is Shashank. I am currently a Masters student. I am trying to 
>>> explore new technologies and new to Neo4j. I have basic idea on nodes, 
>>> relationships and querying the database. I have developed a small database 
>>> in my laptop. I want to integrate it with Java and implement few algorithms 
>>> on the data (like apriori algorithm) for my data mining project.
>>>
>>> Is it a good idea to use Neo4j for data mining. If so, please let me 
>>> know any example that can fetch data from Neo4j server using Java. Also, I 
>>> was wondering whether we can use Tomcat instead of Maven. 
>>>
>>> Your help is very much appreciated.
>>>
>>> Thanks,
>>> Shashank
>>>
>>> -- 
>>> 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.
>>>
>>
>>
> -- 
> 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.
>
>
>

-- 
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.

Reply via email to