From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Re: Problems with BIT datatype and preparedStatment
Date: Mon, 26 Nov 2012 14:12:49 +0100
Message-ID: <k8vprl$vmg$1@ger.gmane.org> (raw)
In-Reply-To: <CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com>
References: <CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
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();
>
> Theorically (I think) it should works, but it answers:
>
> ERROR: column "b" is of type bit but expression is of type boolean
>
> We are working with PG 9.2.1 (one-click-installer on Ubuntu) and JDBC4 9.2-1002
>
> After trying a lot of different types for the pstmt.setXXXX(), we think that there is something not working well, or we are missing something :-)
>
did you try
pstmt.setString(1, "1");
(I find the boolean type much more "descriptive" anyway for true/false columns)
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: Problems with BIT datatype and preparedStatment
In-Reply-To: <k8vprl$vmg$1@ger.gmane.org>
References: <CABX=gB6H6RqrOd9p38rtiomyqqByovAMpmk6zU5vcJwAHpOovw@mail.gmail.com> <k8vprl$vmg$1@ger.gmane.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox