Re: Writing portable SQL code in Java

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "Laurent Duperval" <lduperval(at)microcelli5(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Writing portable SQL code in Java
Date: 2001-05-16 14:58:42
Message-ID: 034f01c0de18$b2dd41c0$230470d1@INSPIRON
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

You might try using a class structure which abstracts out various problems,
and has unique methods for each different implementation

ie a base class which would be something like SQLDatabase which implements
all of the various calls. Then you could extend this for each unique db such
as Oracle. So for oracle you would implement getUnique one way, and for
postgres you would implement the getUnique the postgres way.

This would probably have to be a singleton, and be created at run time.

Of course you could forgo all of the above and just use a persistence layer
such as castor and forget about sql all together ;)

If this is too brief let me know, and I will expand a little more

--dc--

----- Original Message -----
From: "Laurent Duperval" <lduperval(at)microcelli5(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Sent: Wednesday, May 16, 2001 9:59 AM
Subject: [JDBC] Writing portable SQL code in Java

> Hi,
>
> Are there any guidelines for writing portable Java code using different
SQL
> DBMS engines? Specifically, I'm writing code that will be ultimately
> deployed on Oracle. I don't really care for encumbering my disk with 300
MB
> of Oracle stuff, just to have access to a bad ui (sqlplus) and a few
> libraries. So I've started to do the code using Postgres but now, I'm at a
> situation where I'm looking at being forced to install oracle. Here are
some
> of the issues I'm finding:
>
> - setBytes() doesn't work as I expect. I have to use Oracle's RAW type and
I
> haven't been able to use setBytes correctly on Postgres. I'm not sure
why,
> yet. I get cast exceptions, for one but I don't know why that would
> happen.
>
> - sequences don't work the same. In my Java code, I have to get sequence
> numbers. It's fairly easy in Postgres (select nextval ('seq')) but the
> syntax in Oracle is different (select seq.nextval from DUAL).
>
> I have to write Oracle-centric code in my Java stuff and I'm trying to see
> if it's worth it to do some extra work to make it work or not. Anyone have
> any comments on this?
>
> L
>
> --
> Laurent Duperval <mailto:lduperval(at)microcelli5(dot)com>
>
> D'obscures manoeuvres ont eu lieu dans l'ombre et je ferai toute la
lumière
> sur ces ténébreux agissements! C'est du marché noir!
> -Achille Talon
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Laurent Duperval 2001-05-16 15:21:48 Re: Writing portable SQL code in Java
Previous Message Laurent Duperval 2001-05-16 13:59:01 Writing portable SQL code in Java