Re: Connecting to keel's hsqldb?
"Michael Nash JGlobal.com" <[email protected]>
| Newsgroups | gmane.comp.java.keel.user |
|---|---|
| Organization | JGlobal |
| Message-ID | <20040408172725.64f1098b@jglobal> |
Calvin:
Welcome aboard - I'll try to help out, some comments below...
> I'm just getting started with Keel, so forgive me if there are any silly
> mistakes in what follows. I'm on my way to getting persistance working
> with hsqldb and hibernate services, but I've run into a couple of
> problems.
>
> First, I would like to see what hsql has in the database, and have been
> trying to connect to the hsqldb that is running inside keel, but I can't
> get the connect string, user, and password correct. I've tried various
> ports and URLs for the two standard hsql URLs (jdbc:hsqldb:<database>
> and jdbc:hsqldb:hsql://<host>:<port>, including port 9001, which I think
> is the standard port, but I always get a "Connection refused" error. Can
> anybody tell me what the default database url is for hsqldb in keel, or
> which file this would be configured in?
I believe I'm correct in saying that, by default, Keel is running Hsql in "embedded" mode, that is, not as a seperate server process that you can connect to, but from within the same VM. That's why you can't connect to 9001, as it's not listening for connections there. Having said that, Hsql's database files are text, so you can always go have a look in them directly.
> Second, and this is the underlying problem I'm having with hsql and
> hibernate, it seems that I am able to add objects created from
> information a user submitted, but when I retrieve an object later, it
> always seems to return the same object, regardless of what I've set the
> field to for the retrieve.
Now this is a strange one...
> I'm adding like so:
>
> Persistent m = pf.create("tax.ZipTaxRate"); m.setField("newZipCode",
> request.getParameter("newZipCode"));
> m.setField("newTaxRate", request.getParameter("newTaxRate"));
> m.add();
>
> And this works with no errors. For the sake of the example, let's say I
> did this twice, with different zip codes and tax rates each time.
>
> The problem is that when I later try to retrieve an object, it always
> retrieves the first object added, even when the field for the retrieve
> (newZipCode, which is the key) has been set to the zip code of the
> second object.
>
> Here is how I'm trying to retrieve the object:
>
> Persistent m = pf.create("tax.ZipTaxRate"); String zipCode = (String)
> request.getParameter("zipCode"); m.setField("newZipCode", zipCode); //
> zipCode is the value of the second object I added
> m.retrieve();
> ZipRate zipRate = (ZipRate) m.getBean(); // simple bean with two fields,
> newZipCode & newTaxRate
>
> When I do zipRate.getNewTaxRate(), I get the value for the first object,
> not the object that has the key I submitted. Maybe I'm doing something
> wrong here, or perhaps I'm running into some kind of cache issue. Does
> this problem ring a bell for anybody?
No, not really. There shouldn't be a cache issue here at all. I assume the persistent object has a primary key (e.g. the zip code?). At a glance, this code looks correct, but the results you describe definitely dont sound right...
Mike
> --
>
> ThatOne Company
>
> http://www.thatone.com/
>
> _______________________________________________
> User mailing list
> [email protected]
> http://lists.keelframework.org/listinfo.cgi/user-keelframework.org
--
Michael Nash
JGlobal Ltd
Next-Generation Web Application Development and Open Source Support
http://www.jglobal.com
Bahamas Commerce and Trade
Offshore eCommerce Hosting and Business Services
http://www.bahamascommerce.com