Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:41:16+00:00 2026-06-13T07:41:16+00:00

I can retrieve individuals from my ontology using following query: SELECT ?indiv WHERE {

  • 0

I can retrieve individuals from my ontology using following query:

SELECT ?indiv WHERE { ?indiv rdf:type:Fruit  } 

I get results such as Apple, Orange, etc., but when I wrote this query in Java, I get the following exception:

Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " "}" "} "" at line 4, column 41.
Was expecting one of:
    <IRIref> ...
    <PNAME_NS> ...
    <PNAME_LN> ...
    <BLANK_NODE_LABEL> ...
    <VAR1> ...
    <VAR2> ...
    "true" ...
    "false" ...
    <INTEGER> ...
    <DECIMAL> ...
    <DOUBLE> ...
    <INTEGER_POSITIVE> ...
    <DECIMAL_POSITIVE> ...
    <DOUBLE_POSITIVE> ...
    <INTEGER_NEGATIVE> ...
    <DECIMAL_NEGATIVE> ...
    <DOUBLE_NEGATIVE> ...
    <STRING_LITERAL1> ...
    <STRING_LITERAL2> ...
    <STRING_LITERAL_LONG1> ...
    <STRING_LITERAL_LONG2> ...
    "(" ...
    <NIL> ...
    "{" ...
    "[" ...
    <ANON> ...
    "+" ...
    "*" ...
    "/" ...
    "|" ...
    "?" ...

at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse(ParserSPARQL11.java:40)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:132)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:69)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:28)

My code is:

String queryString = " PREFIX ont: <http://www.owl-ontologies.com/fruitOntology.owl#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
SELECT ?indiv WHERE { ?indiv ont:Fruit  } ";

Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
try {
  ResultSet results = qexec.execSelect() ;
  for ( ; results.hasNext() ; )
  {
    QuerySolution soln = results.nextSolution() ;
    Resource y = soln.getResource("y") ; 
    Resource x = soln.getLiteral("x") ;   
    System.out.println(y.getLocalName()+" = "+x.getString()) ;
  }
}
catch(Exception e){
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:41:17+00:00Added an answer on June 13, 2026 at 7:41 am

    That is illegal SPARQL syntax. You want something like:

    PREFIX ....
    SELECT ?indiv WHERE { ?indiv rdf:type ont:Fruit  }
    

    RDF is triples; the triple pattern of interest is where the predciate is rdf:type. Spaces to separate the 3 parts of the pattern are necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I developp a Java application using Windows Desktop Search from which I can retrieve
I was using the following code to retrieve HTML snippets from a database table
I'm trying to retrieve attachments from Mail.app through scriptingbridge. I'm using the following code
I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
I have a situation whereby a thread can retrieve an object from the db,
Using the code described bellow, i can sucessfully retrieve the properties stored into the
Can anyone please help me to retrieve a value <QuoteId> from the attached XML
I am able to get the items from a list view using Lists.GetListItems() function.
Query SELECT ppc.personid, ppc.category, ppc.phonenumber, ppc.createts FROM person_phone_contacts ppc WHERE CURRENT_TIMESTAMP BETWEEN ppc.createts AND
I am using AVCapture foundation to retrieve images (from the iphone 4 front camera)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.