Re: Problems with BIT datatype and preparedStatment

From: Ermengol Bota <ebota(at)uoc(dot)edu>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problems with BIT datatype and preparedStatment
Date: 2012-11-26 17:35:10
Message-ID: CABX=gB5T4nQ+muNnffWK1oxe4CDFq6Mkc33dVpu8K0TnSXmvnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

2012/11/26 Thomas Kellerer <spam_eater(at)gmx(dot)net>

> Ermengol Bota, 26.11.2012 14:00:
>
>> Hello,
>>
>> sql.execute("Create Table jdbc_demo (b bit)");
>> PreparedStatement pstmt = conn.prepareStatement("insert into jdbc_demo
>> values (?)");
>> pstmt.setBoolean(1,true); // There is no way to set a value for the bit
>> field (or I don't know ... :-)
>> pstmt.execute();
>>
>> did you try
>
> pstmt.setString(1, "1");
> (I find the boolean type much more "descriptive" anyway for true/false
> columns)
>
>

Yes we did it, and the result is the same

Error Code: 42804
Message:
ERROR: column "b" is of type bit but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 31

And I agree that boolean is much more better :-)

Actually we solved it using boolean, but I think that may be this could be
a bug... I haven't found anyway to set bit (setInt, setString,
setObject....), so first of all I ask here if someone knows who's wrong, me
or jdbc :-)

Thanks for the answer!
--
* Ermengol *
*************************************************
* Els ordinadors no resolen problemes, *
* simplement executen solucions *
*************************************************

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message dmp 2012-11-26 17:43:59 Re: Problems with BIT datatype and preparedStatment
Previous Message Thomas Kellerer 2012-11-26 13:12:49 Re: Problems with BIT datatype and preparedStatment