You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by neha gupta <ne...@gmail.com> on 2016/11/03 12:37:24 UTC

resultset as string

I have a query which has output of one single string line "My name is ---,
living in city -----, located in country ----.

After query string , I have executed the query

 Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
ResultSet rs = qexec.execSelect() ;
I want this string to be displayed as string:
JOptionPane.showMessageDialog(null, string);

But I dont think I need while(rs.hasNext()) and convert it to string
because resultset only contain one string output at one time.
How can I display the resultset as string?

Re: resultset as string

Posted by Martynas Jusevičius <ma...@graphity.org>.
See ResultSetFormatter:
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSetFormatter.html

On Thu, Nov 3, 2016 at 1:37 PM, neha gupta <ne...@gmail.com> wrote:
> I have a query which has output of one single string line "My name is ---,
> living in city -----, located in country ----.
>
> After query string , I have executed the query
>
>  Query query = QueryFactory.create(queryString);
> QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
> ResultSet rs = qexec.execSelect() ;
> I want this string to be displayed as string:
> JOptionPane.showMessageDialog(null, string);
>
> But I dont think I need while(rs.hasNext()) and convert it to string
> because resultset only contain one string output at one time.
> How can I display the resultset as string?

Re: resultset as string

Posted by Andy Seaborne <an...@apache.org>.
Either
* your query is not returning one line
* you called .next once already and then called it again

Once again you do not provide a complete, minimal example. No one can 
tell which of these is happening.

Read this
http://stackoverflow.com/help/mcve

	Andy


On 03/11/16 13:53, neha gupta wrote:
> It gives me error:
>
> NoSuchElementException: QueryIteratorCloseable
> t
> com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.nextBinding(QueryIteratorBase.java:93)

^^^^^^^^^^^^^^^^^^^

Your version of Jena is out of date.

>
> On Thu, Nov 3, 2016 at 3:35 PM, neha gupta <ne...@gmail.com> wrote:
>
>> Thanks Lorenz, I did not know about this method.
>>
>>
>> On Thu, Nov 3, 2016 at 3:00 PM, Lorenz B. <buehmann@informatik.uni-
>> leipzig.de> wrote:
>>
>>> If you know that there is exactly 1 result why does it not work to call
>>> just once rs.next() ? E.g.
>>>
>>> rs.next().getLiteral(THE_VAR_NAME).getLexicalForm();
>>>
>>> Lorenz
>>>
>>>> I have a query which has output of one single string line "My name is
>>> ---,
>>>> living in city -----, located in country ----.
>>>>
>>>> After query string , I have executed the query
>>>>
>>>>  Query query = QueryFactory.create(queryString);
>>>> QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
>>>> ResultSet rs = qexec.execSelect() ;
>>>> I want this string to be displayed as string:
>>>> JOptionPane.showMessageDialog(null, string);
>>>>
>>>> But I dont think I need while(rs.hasNext()) and convert it to string
>>>> because resultset only contain one string output at one time.
>>>> How can I display the resultset as string?
>>>>
>>> --
>>> Lorenz B�hmann
>>> AKSW group, University of Leipzig
>>> Group: http://aksw.org - semantic web research center
>>>
>>>
>>
>

Re: resultset as string

Posted by neha gupta <ne...@gmail.com>.
It gives me error:

NoSuchElementException: QueryIteratorCloseable
t
com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.nextBinding(QueryIteratorBase.java:93)

On Thu, Nov 3, 2016 at 3:35 PM, neha gupta <ne...@gmail.com> wrote:

> Thanks Lorenz, I did not know about this method.
>
>
> On Thu, Nov 3, 2016 at 3:00 PM, Lorenz B. <buehmann@informatik.uni-
> leipzig.de> wrote:
>
>> If you know that there is exactly 1 result why does it not work to call
>> just once rs.next() ? E.g.
>>
>> rs.next().getLiteral(THE_VAR_NAME).getLexicalForm();
>>
>> Lorenz
>>
>> > I have a query which has output of one single string line "My name is
>> ---,
>> > living in city -----, located in country ----.
>> >
>> > After query string , I have executed the query
>> >
>> >  Query query = QueryFactory.create(queryString);
>> > QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
>> > ResultSet rs = qexec.execSelect() ;
>> > I want this string to be displayed as string:
>> > JOptionPane.showMessageDialog(null, string);
>> >
>> > But I dont think I need while(rs.hasNext()) and convert it to string
>> > because resultset only contain one string output at one time.
>> > How can I display the resultset as string?
>> >
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
>

Re: resultset as string

Posted by neha gupta <ne...@gmail.com>.
Thanks Lorenz, I did not know about this method.


On Thu, Nov 3, 2016 at 3:00 PM, Lorenz B. <
buehmann@informatik.uni-leipzig.de> wrote:

> If you know that there is exactly 1 result why does it not work to call
> just once rs.next() ? E.g.
>
> rs.next().getLiteral(THE_VAR_NAME).getLexicalForm();
>
> Lorenz
>
> > I have a query which has output of one single string line "My name is
> ---,
> > living in city -----, located in country ----.
> >
> > After query string , I have executed the query
> >
> >  Query query = QueryFactory.create(queryString);
> > QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
> > ResultSet rs = qexec.execSelect() ;
> > I want this string to be displayed as string:
> > JOptionPane.showMessageDialog(null, string);
> >
> > But I dont think I need while(rs.hasNext()) and convert it to string
> > because resultset only contain one string output at one time.
> > How can I display the resultset as string?
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Re: resultset as string

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
If you know that there is exactly 1 result why does it not work to call
just once rs.next() ? E.g.

rs.next().getLiteral(THE_VAR_NAME).getLexicalForm();

Lorenz

> I have a query which has output of one single string line "My name is ---,
> living in city -----, located in country ----.
>
> After query string , I have executed the query
>
>  Query query = QueryFactory.create(queryString);
> QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
> ResultSet rs = qexec.execSelect() ;
> I want this string to be displayed as string:
> JOptionPane.showMessageDialog(null, string);
>
> But I dont think I need while(rs.hasNext()) and convert it to string
> because resultset only contain one string output at one time.
> How can I display the resultset as string?
>
-- 
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center