A custom Neo4j procedure that allows SPARQL-within-SQL queries to be returned in Neo4j over JDBC, with support for virtuoso.jdbc4.VirtuosoExtendedString and virtuoso.jdbc4.VirtuosoRdfBox classes.
-
Download the best matching .JAR file from the Releases Section and the Virtuoso JDBC Driver into your Neo4j installation's
pluginsdirectory -
Open your
neo4j.conffile and addopenlink.*to yourdbms.security.procedures.unrestrictedparameter value. -
Restart your Neo4j instance.
-
Test that the custom procedure has successfully installed by running:
SHOW PROCEDURES YIELD name
WHERE name STARTS WITH 'openlink'
RETURN name;
- If successful, you can now use openlink.virtuoso_jdbc_connect()
- Clone the git repo using
git clone - Build the .JAR using
mvn clean package - Copy the .JAR and included JDBC Driver to your Neo4j installation's
pluginsdirectory. - Open your
neo4j.conffile and addopenlink.*to yourdbms.security.procedures.unrestrictedparameter value. - Restart your Neo4j instance.
- Test that the custom procedure has successfully installed by running:
SHOW PROCEDURES YIELD name
WHERE name STARTS WITH 'openlink'
RETURN name;
- If successful, you can now use openlink.virtuoso_jdbc_connect()
The Procedure uses the following parameters
- jdbc_url: Your JDBC URL string or variable
- query: Your SQL or SPARQL-within-SQL query
- read/write (default = null)
- 'r' = read
- 'rw' = read/write
- It is recommended to apply correct privileges on your Virtuoso instance rather than fully depending on this parameter.
A basic Virtuoso JDBC URL uses the following format:
jdbc:virtuoso://:<Port#>/DATABASE=/UID=/PWD=/
Returned SQL or SPARQL-within-SQL Query Results can be further queried and manipulated using Cypher
WITH 'jdbc:virtuoso://localhost:1111/UID={username}/PWD={password}/CHARSET=UTF-8' AS url
CALL openlink.virtuoso_jdbc_connect(
url,
'SPARQL SELECT ?person1 ?person2 WHERE { SERVICE <https://linkeddata.uriburner.com/sparql/>{ SELECT * FROM <urn:analytics> WHERE {?person1 foaf:knows ?person2} }}',
'r'
) YIELD value
UNWIND value AS row
WITH row['person1'] AS person1, row['person2'] AS person2
MERGE (p1:Person {id: person1})
MERGE (p2:Person {id: person2})
MERGE (p1)-[:KNOWS]->(p2);
