I'm using SpringBoot to develop an application combining Apache Jena with an OpenLink Virtuoso Service instance. Checking this guide OpenLink Documentation, I'm moving as follows:
- Set the pom (SpringBoot is version 2.7):
<dependency>
<!-- http://download3.openlinksw.com/uda/virtuoso/jdbc/virtjdbc4.jar -->
<groupId>com.openlink.virtuoso</groupId>
<artifactId>virtjdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<!--http://download3.openlinksw.com/uda/virtuoso/rdfproviders/jena/30/virt_jena3.jar-->
<groupId>com.openlink.virtuoso</groupId>
<artifactId>virt_jena3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>3.0.0</version>
</dependency>
Set the application.properties
virtuoso.url=jdbc:virtuoso://localhost:1111 virtuoso.username=dba virtuoso.password=dbaCreate a bean:
public class VirtuosoTransactMain { @Bean(name = "mainVirtuosoGraphManager") @Primary public VirtGraph getVirtualGraph(@Value("${virtuoso.url}") String url, @Value("${virtuoso.username}") String username, @Value("${virtuoso.password}") String password) { VirtGraph set = new VirtGraph(url,username,password); return set; } }Test
@SpyBean @Qualifier("mainVirtuosoGraphManager") public VirtGraph getVirtualGraph; @Test public void testConnection() { Query sparql = QueryFactory.create("SELECT * WHERE { GRAPH ?graph { ?s ?p ?o } } limit 100"); VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, getVirtualGraph); ResultSet results = vqe.execSelect(); assertTrue(results.getRowNumber()>0); }
The test fails because the result set seems empty. No logs or exceptions are thrown.
Addendum: Port 111 is ok.
ComputerName : localhost
RemoteAddress : 127.0.0.1
RemotePort : 1111
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
TcpTestSucceeded : True
Edit: The query is correctly performed, but I have always 0 as number of result rows.
Edit: The problem is my personal understanding of method "getRowNumber".
The code is correct, the problem derives from my misundertanding of the method "getRowNumber" (which gives the current row number of the result set during iteration).