|
Hi, I am a completely beginner to sparql. my problem is that I don't know even where I have to write the sparql queries. (for example for writing java code or RDF we can use eclipse), but I don't know how to start with Sparql( I used this tutorial http://jena.apache.org/tutorials/sparql.html but here I couldn't find where I have to write these queries). thanks |
|
For a code specific tutorial you want to look at the ARQ documentation which is Jena's SPARQL processor That covers how to execute queries in code whereas the documentation you linked only covers executing queries on the command line Edit I updated the documentation page you linked so it more clearly points users who know SPARQL and want to run queries in code to the ARQ documentation |
|
Assuming you are using Eclipse to edit your Java project. So, if you wanna run SPARQL query, first, you need kind of SPARQL processor, like ARQ, on the java build path. Then, obviously, you need write SPARQL query. there are two ways, i know so far. Solution 1: To write query directly in your java code, like:
Solution 2: To wirte the SPARQL queries you need in a *.txt file under your java project, then you can use java method to call the specific query to execute according to the given query name. The details you can find in Pellet-->examples-->src, where there are many basic query examples, I think, will be helpful to you .(Of course, you can find lots of useful information in other places) Hope the above answer is helpful to you. |
|
Using the first example from http://jena.apache.org/tutorials/sparql_query1.html in the tutorial you point to, you write the query in the file passed as the --query parameter to the sparql.bat batch file. In that particular example, you would write the query (or include the query shown in the tutorial) in the file docTutorialq1.rq, and then the following command runs that query against data stored in the file docTutorialvc-db-1.rdf (assuming that you've set the ARQROOT environment variable as the tutorial also describes): batsparql.bat --data=docTutorialvc-db-1.rdf --query=docTutorialq1.rq |

