BUG #1646: ERROR: column "mycolumn" is of type boolean but expression is of type character

Lists: pgsql-bugs
From: "Kjh" <kjh(at)networks(dot)nera(dot)no>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1646: ERROR: column "mycolumn" is of type boolean but expression is of type character
Date: 2005-05-04 12:18:30
Message-ID: 20050504121830.42759F0B10@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1646
Logged by: Kjh
Email address: kjh(at)networks(dot)nera(dot)no
PostgreSQL version: 8.0
Operating system: windows XP
Description: ERROR: column "mycolumn" is of type boolean but
expression is of type character
Details:

newest drivers (JDBC3)
deployed it with JBoss 3.2.6

Indeed, the entity bean has fields of java-type Boolean and the database has
fields of type boolean, but the application server seems to send it to the
database as "true" or "false" strings. That is what the errormessage
indicates to me anyway: ERROR: column "mycolumn" is of type boolean but
expression is of type character. (Though I am not aware of how to verify
this other than changing column type varchar(5) which I have tried -
unfortunately, this had lots of other undesired side-effects even though it
worked in some cases.)

Entity beans with Boolean types works fine with mysql and mssql, though with
the BIT type in the database, instead of boolean. However, if I try to use
the BIT type, I bump into another error: My data base SEED TOOL fails to
load data with the following error ERROR: column "mycolumn" is of type bit
but expression is of type boolean

sigh(!)
please help.
Kjetil


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kjh <kjh(at)networks(dot)nera(dot)no>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1646: ERROR: column "mycolumn" is of type boolean
Date: 2005-05-04 21:51:59
Message-ID: 427943FF.20202@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Kjh wrote:
> The following bug has been logged online:
>
> Bug reference: 1646
> Logged by: Kjh
> Email address: kjh(at)networks(dot)nera(dot)no
> PostgreSQL version: 8.0
> Operating system: windows XP
> Description: ERROR: column "mycolumn" is of type boolean but
> expression is of type character
> Details:
>
> newest drivers (JDBC3)
> deployed it with JBoss 3.2.6
>
> Indeed, the entity bean has fields of java-type Boolean and the database has
> fields of type boolean, but the application server seems to send it to the
> database as "true" or "false" strings. That is what the errormessage
> indicates to me anyway: ERROR: column "mycolumn" is of type boolean but
> expression is of type character. (Though I am not aware of how to verify
> this other than changing column type varchar(5) which I have tried -
> unfortunately, this had lots of other undesired side-effects even though it
> worked in some cases.)

Which PreparedStatement.set...() method is being called to set the value
for this column?

To set a boolean-typed parameter, you shoud use
PreparedStatement.setBoolean(...), PreparedStatement.setObject(...,
Types.BIT), or PreparedStatement.setObject(..., Types.BOOLEAN).

If the application server is using setString() to send a boolean value,
that's where the bug lies.

-O