Re: getXXX methods

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: getXXX methods
Date: 2004-07-06 20:23:07
Message-ID: 1089145387.1506.65.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Once possibility is to use Double.parseDouble(s).byteValue()

so the code would become

try
{
Byte.parseByte(s)
}
catch(NumberFormatException e)
{
try
{
return Double.parseDouble(s).ByteValue();
}
catch( NumberFormatException ne )
{
throw exception;
}
}

Dave
On Tue, 2004-07-06 at 14:46, Kris Jurka wrote:
> On Fri, 2 Jul 2004, Dave Cramer wrote:
>
> > There is a table in the jdbc spec which suggests that
> > there is a preferred method for getting the column information, and at
> > non-preferred method.
> >
> > would all the numeric values be truncated ?
> >
> > What do we do with char, varchar, longvarchar ?
>
> It's tough to say. Looking at the current situation for retrieving double
> values with getInt() the current driver will throw an Exception on a out
> of range value because it starts with a String and uses Integer.parseInt()
> on it. Contrast this with the result of
>
> Double d = new Double(Double.MAX_VALUE);
> System.out.println(d.intValue());
>
> which truncates the double to Integer.MAX_VALUE. The javadocs are
> useless, but I prefer the Exception to silent truncation, so I would
> suggest getByte can be used on any integer value of -128 to 127 regardless
> of its storage form (like text). The question of comparing floating point
> numbers should be the same, but we may run into problems when 1 is
> represented as 1.00000001.
>
> Kris Jurka
>
>
>
> !DSPAM:40eaf9e7148133410918667!
>
>
--
Dave Cramer
519 939 0336
ICQ # 14675561

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-07-06 21:01:15 Re: getXXX methods
Previous Message Kris Jurka 2004-07-06 18:46:07 Re: getXXX methods