best way to store the results of a query?

From: Shailan (shailan_at_ureach.com)
Date: 10/07/04


Date: 7 Oct 2004 09:05:17 -0700

Hi

I was wondering what the common ways to store the results of a JDBC
query were. I have recently migrated from Perl, and am used to storing
the results in a hash. Is there a similar data structure that can
easily handle the results of the query. I have tried HashMap, but cant
figure out how to get a key to map to another HashMap internally
without explicitly creating the internal HashMaps first.

E.g.
The query is something like this:
select animal, type, name from animals;

and the result set is:

Animal Type Name
dog husky Bella
dog poodle Alfie
cat manc Gus

I want the data structure to look like this:

dog => husky => Bella
       poodle => Alfie
cat => manc => Gus

that is:
1) 2 top level keys - dog and cat
2) the 'dog' key pointing to another HashMap which itself has 2 keys -
husky and poodle, with the value for husky being Bella and the value
for poodle, Alfie
3) the 'cat' key pointing to another HashMap containing one key-value
pair, manc => Gus

Alternatively, is there some better way to store the results rather
than trying to duplicate Perl hashes?

Thank you
Shailan



Relevant Pages

  • Re: Confused by mysqli
    ... When I started using MySQL with Perl back in 1998, ... fetch_assocon a query I prepared with bind variables, ... So I had it print out its eval string that it was trying to run. ... PHP will fail to run at all, because bind_result will not have enough ...
    (comp.lang.php)
  • Re: Parameter default value
    ... your Test.mdb open it & look at the query you've created. ... It looks like an Access DAO QueryDef, but acts like a Stored Procedure - the default gets set, which I can't find any documentation on why it does that. ... Dim cat As Object ... Note that in the parameters declaration I have assigned the default as ...
    (microsoft.public.access.queries)
  • RE: Perl Performance Help.
    ... commands to read from / dump to a file. ... you should start by running the equivalent query from ... Subject: Perl Performance Help. ... take less time to fetch the data and assign to an array. ...
    (perl.dbi.users)
  • RE: Finding row size of a query
    ... You might be able to do everything in perl. ... Finding row size of a query ... The only way I am aware of is using ESQL/C DESCRIBE. ...
    (comp.databases.informix)
  • execute failed: Lost connection to MySQL server during query(2013)
    ... I have a perl script that uses DBI but it times out on queries that take over 30 seconds. ... The same query works fine if I issue it directly from the mysql client. ... The message printed when it times out is: execute failed: Lost connection to MySQL server during query. ...
    (perl.dbi.users)