[greenstone-devel] Re: Using GDBM package

From Katherine Don
DateTue, 21 Feb 2006 15:47:44 +1300
Subject [greenstone-devel] Re: Using GDBM package
In-Reply-To (1140145906-43f53ef216d69-webmail-ait-ac-th)
Hi

What GDBM package are you using?

I use au.com.pharos.gdbm.GdbmFile, and here is a sample of my code:

to create the database:
GdbmFile db_ = new GdbmFile(filename, mode);
db_.setKeyPacking(new StringPacking());
db_.setValuePacking(new StringPacking());

to get the value for a particular key:
String info = (String)db_.fetch(main_key);

Perhaps its the set Key and Value Packing bits that you need?

Regards,
Katherine

VoHa.Quang@ait.ac.th wrote:
> Hi,
> Do you have documents or any examples about using the gdbm package? I donâ–ˇt
> understand the "key" and "value" concepts that are used in the gdbm source.
>
> My code:
> String dbFile = "test.ldb";
> try {
> GdbmFile gdbm = new GdbmFile(dbFile, GdbmFile.READER);
> Enumeration element = gdbm.keys();
> while (element.hasMoreElements()) {
> Object o = element.nextElement();
> System.out.println(o.toString());
> }
> } catch (Exception e) {System.out.println(e.toString());}
>
> and result is:
> [B@10385c1
> [B@42719c
> [B@30c221
> [B@119298d
> [B@f72617
> ....
>
> if can, pls show me where i can get examples or user-guide document about the
> gdbm package.
>
> Thank,
>
> vd
>
>
>
> ----------------------------------------------------------
> This mail sent through AIT WebMail : http://www.ait.ac.th/
>
>
>