cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

I have a Community Edition 4.2.5 database that I'd like to be able to query via Scala code. When I pop the db open using the web interface and launch a query, it works great. However, when I launch the same query using Neo4j embedded, no results are returned. The code seems to be connecting to the database, as I don't see a "Database Not Found" error, but I have been unable to retrieve any data from it using this method. If it matters, I'm building the project with SBT version 1.5.0. Code snippet below:

def search_db()
{
val dir = new File("path_to_db_dir")
val managementService = new DatabaseManagementServiceBuilder(dir)
.loadPropertiesFromFile("path_to_config_file")
.build()
val graphDb = managementService.database("db_name")
val transaction = graphDb.beginTx()
val query: String =
"MATCH (n:Page) RETURN n LIMIT 25"
val result = transaction.execute(query)
println(result.hasNext())
}

Neo4j dependency in build.sbt:

libraryDependencies ++= Seq(
"org.neo4j" % "neo4j" % "4.2.5"
)

Version history
Last update:
‎04-19-2021 12:27 PM
Updated by:
Contributors