[MonetDB-users] MonetDB/XQuery JDBC result issue
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
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
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 (2)
-
Rob Fynes
-
Wouter Alink