Return-Path: X-Original-To: apmail-incubator-jena-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-jena-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D9CB9F17 for ; Thu, 19 Jan 2012 05:39:21 +0000 (UTC) Received: (qmail 63226 invoked by uid 500); 19 Jan 2012 05:39:20 -0000 Delivered-To: apmail-incubator-jena-dev-archive@incubator.apache.org Received: (qmail 63008 invoked by uid 500); 19 Jan 2012 05:39:12 -0000 Mailing-List: contact jena-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-dev@incubator.apache.org Delivered-To: mailing list jena-dev@incubator.apache.org Received: (qmail 62979 invoked by uid 99); 19 Jan 2012 05:39:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2012 05:39:09 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ashwinib@smartnapps.com designates 216.32.181.185 as permitted sender) Received: from [216.32.181.185] (HELO ch1outboundpool.messaging.microsoft.com) (216.32.181.185) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2012 05:39:01 +0000 Received: from mail93-ch1-R.bigfish.com (10.43.68.241) by CH1EHSOBE006.bigfish.com (10.43.70.56) with Microsoft SMTP Server id 14.1.225.23; Thu, 19 Jan 2012 05:38:39 +0000 Received: from mail93-ch1 (localhost [127.0.0.1]) by mail93-ch1-R.bigfish.com (Postfix) with ESMTP id 61F6A6A01BF for ; Thu, 19 Jan 2012 05:38:39 +0000 (UTC) X-SpamScore: -5 X-BigFish: PS-5(zz542Mzz1202hzz8275dhz2fhc1bhc31hc1ah2a8h5c0h668h839h944h) X-Forefront-Antispam-Report: CIP:207.46.198.81;KIP:(null);UIP:(null);IPV:NLI;H:CH1PRD0502HT008.namprd05.prod.outlook.com;RD:none;EFVD:NLI X-FB-SS: 13, Received-SPF: pass (mail93-ch1: domain of smartnapps.com designates 207.46.198.81 as permitted sender) client-ip=207.46.198.81; envelope-from=ashwinib@smartnapps.com; helo=CH1PRD0502HT008.namprd05.prod.outlook.com ;.outlook.com ; Received: from mail93-ch1 (localhost.localdomain [127.0.0.1]) by mail93-ch1 (MessageSwitch) id 1326951518760610_19921; Thu, 19 Jan 2012 05:38:38 +0000 (UTC) Received: from CH1EHSMHS001.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.242]) by mail93-ch1.bigfish.com (Postfix) with ESMTP id AD49B60042 for ; Thu, 19 Jan 2012 05:38:38 +0000 (UTC) Received: from CH1PRD0502HT008.namprd05.prod.outlook.com (207.46.198.81) by CH1EHSMHS001.bigfish.com (10.43.70.1) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 19 Jan 2012 05:38:38 +0000 Received: from SNETAPPS01 (122.167.10.183) by pod51010.outlook.com (10.42.119.79) with Microsoft SMTP Server (TLS) id 14.15.29.1; Thu, 19 Jan 2012 05:38:37 +0000 From: Ashwini Balu To: References: In-Reply-To: Subject: RE: ERROR IN SPARQL Query Date: Thu, 19 Jan 2012 11:08:35 +0530 Organization: SMARTNAPPS Message-ID: <000601ccd66c$997fe6d0$cc7fb470$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AczWaFbppeRvxVEMQTy4Bi8ERbq5WQAA72Ew Content-Language: en-in X-Originating-IP: [122.167.10.183] X-OriginatorOrg: smartnapps.com Hi, Check out SPARQL query syntax http://www.w3.org/TR/rdf-sparql-query/ -----Original Message----- From: Nallanchakravarthy Ramadurai Ananthanarayanan [mailto:drnrananthanarayanen@gmail.com] Sent: 19 January 2012 10:37 To: jena-dev@incubator.apache.org Subject: ERROR IN SPARQL Query package QueryBuilder; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; public class Query4 { public static void main(String[] args) throws IOException { InputStream in = new FileInputStream(new File("d:/PROJECT/vc-db-1.rdf")); // Create an empty in-memory model and populate it from the graph Model model = ModelFactory.createMemModelMaker().createDefaultModel(); model.read(in,null); // null base URI, since model URIs are absolute in.close(); // Create a new query String queryString= "{ SELECT ?g WHERE { ?y Given ?g . FILTER regex(?g, 'r', 'i')}}"; Query query = QueryFactory.create(queryString); // Execute the query and obtain results QueryExecution qe = QueryExecutionFactory.create(query, model); ResultSet results = qe.execSelect(); // Output query results ResultSetFormatter.out(System.out, results, query); // Important - free up resources used running the query qe.close(); } } Error ------- Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " "{" "{ "" at line 1, column 1. Was expecting one of: "base" ... "prefix" ... "select" ... "describe" ... "construct" ... "ask" ... 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) at QueryBuilder.Query4.main(Query4.java:25)