Re: JDBC & custom type of variable types (!)

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC & custom type of variable types (!)
Date: 2013-11-27 14:02:28
Message-ID: CADK3HHJkeks09bMK04PG3HrUV7OHaYydYFNZPUSLOivkp+9snQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I expect that if it has a null you will have a problem, however I'm sure
there is a quick way to test this. Just populate some data with NULL

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On Wed, Nov 27, 2013 at 4:04 AM, Marc Mamin <M(dot)Mamin(at)intershop(dot)de> wrote:

> Hello,
>
> I'd like to retrieve a custom type from a result set,
> but problem: I don't know exactly the structure.
> It may be float/text or int/text, so I'd need to map it to one of those
> java custom types:
>
> deciType <Double,String>;
> intType <Long, String>;
>
>
> Can I rely on a ClassCastException as below to find the correct matching?
> even when the custom type has NULL(s) in it ?
>
> Or is there a better approach ?
>
> case Types.STRUCT:
>
> try
> {
> foo = (intType)resultset1.getObject(1);
> }
> catch (ClassCastException e)
> {
> blah = (deciType)resultset1.getObject(1);
> }
>
> (Postgres 9.3 , JDBC4 Postgresql Driver, Version 9.3-1100)
>
> many thanks,
>
> Marc Mamin
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Johnston 2013-11-27 16:13:46 Re: JDBC & custom type of variable types (!)
Previous Message Marc Mamin 2013-11-27 09:04:15 JDBC & custom type of variable types (!)