This project has moved and is read-only. For the latest updates, please go here.

Connect to a BrightstarDB triplestore and query it by using dotnetRDF

Nov 21, 2014 at 8:17 AM
I've copied this message across from the old discussion group because it may well be useful to a number of people and I would welcome any comments / feedback.
Hi,
I'm completely new to BrighstarDB but we are considering its use. I'd like to ask whether it could be possible to connect to RDF data triplestores stored in BrightstarDB from
a software based on the dotnetRDF set of libraries. From what I have seen in the "connections" documentation page, it seems like from BrighstarDB there exists a connection type
to connect from there to dotnetRDF, but I'm not sure about the other way round, which is what I would be interested in??
thanks in advance

kind regards,
Iván
Hi Ivan,

BrightstarDB does implement a standard SPARQL query and update endpoint for its stores [1], so if you run it as a server you can use DotNetRDF to access it through an appropriate storage provider [2].

To use DNR to access an embedded BrightstarDB you would need to wrap our IBrightstarService interface with and implementation of the appropriate DNR interfaces (probably INativelyQueryableStore at a minimum).

The main downside to this would be that you won't have access to any of the non-standard features of BrightstarDB (such as querying at commit points, or our more extensive transactional update operation). Of course, that may not be an issue for you if you are looking to create a layer for portability between the different stores that DNR supports.

BTW: can I ask you to please send any future questions to our Codeplex discussion forum [3] rather than to this group.

Cheers

Kal

[1] http://brightstardb.readthedocs.org/en/latest/SPARQL_Endpoint/
[2] https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Storage/Providers
[3] http://brightstardb.codeplex.com/discussions
Dec 1, 2014 at 12:00 PM
Hi again,
I'm currently trying to make a first connection from a .NET project with dotnetRDF, to a BrightstarDB remote endpoint in which I have a triplestore.
The code I use is quite simple, just try to connect and execute a "trival" SPARQL query, as follows (<IP>, <PORT> and <STORE_NAME> stand for the existing address
and triplestore name I want to access):

namespace ConsoleApplication3
{
class ReadFromBrightstarDB
{
    static void Main(string[] args)
    {
        //Create a connection to BrightstarDB SPARQL Query endpoint
        SparqlConnector connect = new SparqlConnector(new Uri("http://<IP>:<PORT>/brightstar/<STORE_NAME>"));
        PersistentTripleStore store = new PersistentTripleStore(connect);

        Object results = store.ExecuteQuery("SELECT * WHERE {?s ?p ?o}");
        if(results is SparqlResultSet)
        {
            //Print out the results
            SparqlResultSet rset = (SparqlResultSet)results;
            foreach (SparqlResult result in rset)
            {
                Console.WriteLine(result.ToString());
            }
        }

    }
}

}

When executing, I obtain an exception entitled "RDFParseException was unhandled", with the following description:

An unhandled exception of type 'VDS.RDF.Parsing.RdfParseException' occurred in dotNetRDF.dll
Additional information: Unable to Parse a SPARQL Result Set from the provided XML since the Document Element is not a <sparql> element!

Any help would be appreciate, I'm quite new to .NET in general and BrightStarDB as well as to SparQL, so maybe there is a very silly issue here but I couldn't find it yet.
Thanks!
Iván
Dec 1, 2014 at 1:23 PM
Hi Iván

I think the problem is that you have the wrong URL for the SPARQL endpoint. The SPARQL endpoint for a BrightstarDB store is http://<IP>:<PORT>/brightstar/<STORE_NAME>/sparql.

See http://brightstardb.readthedocs.org/en/latest/SPARQL_Endpoint/ for all the details.

Cheers

Kal