Re: [MonetDB-users] MonetDB/XQuery JDBC result issue
Hello Rob,
Yes, the good thing about the JDBC interface is that the result is streamed
to the client, so that there is no large memory-consumption on the
client-side. However, be aware that, due to the way MonetDB works
internally, the whole result is first computed and kept in memory at the
server, before it is shipped to the client. This will for most use-cases not
be a problem, but if you are calculating huge result sets it might. If you
only fetch the first 10 rows of a result at the client, you may want to wrap
a "subsequence(<your-query>, 1, 10)" around your query.
Kind regards,
Wouter
On Fri, Mar 4, 2011 at 3:42 PM, Rob Fynes
Hi Wouter,
Thanks for the response. You were right about that, it's working fine now. I was thrown slightly when I saw the MonetDB documentation that said "The result comes back as a single-row single-column multi-line string result". I figured that the 'entire' set of results would be stuffed into one row and one column in the result set object. In retrospect, this wouldn't make much sense, since you could end up with a *really* big string!
Thanks, -Rob
On Wed, Mar 2, 2011 at 1:46 PM, Wouter Alink
wrote: Dear Rob Fynes,
You have already provided the answer in your email. XQuery specifies that a result is actually a sequence of items. The "XQueryResult"-node has only been added to convert the actual result sequence into a valid XML fragment. Using XQuery over JDBC works like SQL; you can iterate over the results. There is no artificial XQueryResult-node added.
For example:
ResultSet rs = conn.executeQuery("...."); while(rs.next()) { .. do something with the result .. }
With kind regards, Wouter Alink
On Tue, Mar 1, 2011 at 10:13 PM, Rob Fynes
wrote: Hello,
I've been having an issue with MonetDB/XQuery using the JDBC driver. Essentially, when I supply an *XPath* query such as the following:
pf:collection("collection_name")//stations[date/year>=2010]
... using the mclient utility, there's no problem. The result is an <XQueryResult> root node containing all the relevant 'stations' nodes as requested by the query. However, if I issue the same query to the server from a Java application using the JDBC driver for MonetDB, the string result that is returned merely contains one 'stations' node (the first one that gets processed, I think).
My guess is that the resultset (of 'stations' nodes) is not being wrapped in a root node, as is the case when querying using the mclient utility. But I'm unsure if this due to a bug, or if there's something that I'm not doing correctly.
I'm also aware that this issue can be resolved by modifying the query (when using JDBC) to something such as:
<result> { pf:collection("collection_name")//stations[date/year>=2010] } </result>
... but I have reasons for not wanting to do this. Any help is much appreciated. If anyone needs more information, just let me know (and if it makes any difference, I'm running a local server instance).
Cheers, -Rob
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
participants (1)
-
Wouter Alink