问题
What I want to do is passing data from sesame to virtuoso.
Here are my codes:
public static void sesame2virtuoso(String server, String repo, String graphName) throws IOException, RepositoryException {
//connect sesame
HTTPRepository repository = new HTTPRepository(server, repo);
repository.setUsernameAndPassword(PropertiesUtil.PropValues("user"), PropertiesUtil.PropValues("password"));
repository.initialize();
RepositoryConnection connection = repository.getConnection();
ValueFactory factory = connection.getValueFactory();
try {
RepositoryResult<Statement> statements = connection.getStatements(null, null, null, false);
Statement statement;
String sub, pre, obj;
VirtGraph graph = new VirtGraph(graphName, URL, "dba", "dba");
int count = 0;
while (statements.hasNext()) {
statement = statements.next();
sub = statement.getSubject().stringValue();
pre = statement.getPredicate().stringValue();
obj = statement.getObject().stringValue();
Node sub1 = Node.createURI(sub);
Node pre1 = Node.createURI(pre);
Node obj1 = Node.createURI(obj);
try {
graph.add(new Triple(sub1, pre1, obj1)); } catch (Exception e) {
continue;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
I used it in a maven project. So I searched some poms for that, but all of them can't work.
I think the reason is the dependencies versions are wrong or something wrong happened with my idea IDE. What should I do?
Thank you for any help.
回答1:
These libraries ( virt_jena3.jar
and virtjdbc4.jar
) do not exist in any public maven repository.
It's not your fault, is the Openlink people's fault.
If you want them, here are the steps.
1. Download them on your computer
wget http://download3.openlinksw.com/uda/virtuoso/rdfproviders/jena/30/virt_jena3.jar -P /tmp/
wget http://download3.openlinksw.com/uda/virtuoso/jdbc/virtjdbc4.jar -P /tmp/
2. Install them in your local maven repository
mvn install:install-file -q \
-Dfile=/tmp/virt_jena3.jar \
-DgroupId=com.openlink.virtuoso \
-DartifactId=virt_jena3 \
-Dversion=3.0 \
-Dpackaging=jar \
-DgeneratePom=true
mvn install:install-file -q \
-Dfile=/tmp/virtjdbc4.jar \
-DgroupId=com.openlink.virtuoso \
-DartifactId=virtjdbc4 \
-Dversion=4.0 \
-Dpackaging=jar \
-DgeneratePom=true
3. Add the dependencies to your pom
<!-- These do not have a Maven repository -->
<dependency>
<groupId>com.openlink.virtuoso</groupId>
<artifactId>virtjdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.openlink.virtuoso</groupId>
<artifactId>virt_jena3</artifactId>
<version>3.0</version>
</dependency>
4. Add the information about the steps to your documentation
Alternatively you could use the <system>
scope to point to the jars, but this will generate problems if you want to create an uber-jar. If you still want to try, here is the fragment to add in the <dependency>
tag
<scope>system</scope>
<systemPath>/path/to/jar/virtjdbc4.jar</systemPath>
回答2:
You can download from this link Virtuoso maven dependency. Now, download the jar and related pom file from the directory and put it manually to maven repository directory of your computer location.
来源:https://stackoverflow.com/questions/41137342/is-there-any-usable-dependency-for-virtuoso-jena-driver