Re: Using boolean '1' in jdbc2

From: Rene Pijlman <rene(at)lab(dot)applinet(dot)nl>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL jdbc list <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Using boolean '1' in jdbc2
Date: 2001-09-13 19:46:41
Message-ID: 1k22qtoo56se2serm4gt9q9mc8uk70st3q@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thu, 13 Sep 2001 15:29:38 -0400 (EDT), you wrote:
>> Bruce Momjian writes:
>> > I noticed that jdbc1 getBoolean allows '1', while jdbc2 does not. The
>> > following patch makes jdbc2 accept '1' also. Is this OK?
>>
>> Why? Booleans always come out as 't' or 'f'.
>
>Someone emailed me privately that they wanted to use '1' for
>boolean. No idea why, and no idea why jdbc1 has it.

In jdbc1 the string to boolean conversion is implemented within
getBoolean() itself, which interprets data from the PostgreSQL
backend.

In jdbc2 its implemented in a helper method
ResultSet.toBoolean(), which is public, probably because its now
also used in the new Array feature.

Perhaps someone is now using ResultSet.toBoolean() as a utility
method. I don't think that's a good idea. Even though its public
its not part of any published interface. So anyone who wants to
convert 1 to true should use his own method. We could rule this
out by declaring the method protected or package (no access
specifier).

This doesn't explain why jdbc1 accepts '1' though. Anyone?

Regards,
René Pijlman <rene(at)lab(dot)applinet(dot)nl>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2001-09-14 01:50:02 Re: Using boolean '1' in jdbc2
Previous Message Marc G. Fournier 2001-09-13 19:45:36 Re: [JDBC] Re: What needs to be done?