pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bst <bst_co@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Bit string type in PreparedStatement
Date: Thu, 14 Apr 2005 08:45:07 -0700 (PDT)
Message-ID: <20050414154508.66799.qmail@web50407.mail.yahoo.com> (raw)

I have a table with a bit string field
CREATE TABLE test (a BIT(8));
 
When I get the type of this filed from Java
 
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT a FROM
test");
ResultSetMetaData rsmd = rs.getMetaData();
int type = rsmd.getColumnType(1);
String name = rsmd.getColumnTypeName(1);
 
I get
 
type=-7 that is equal to java.sql.Types.BIT
name=bit
 
 
Now I'd like to set the field in a PreparedStatement
PreparedStatement update =
connection.prepareStatement("UPDATE test SET a=?");
update.setObject(1, "B10101010", java.sql.Types.BIT);
update.executeUpdate();
 
and I get
org.postgresql.util.PSQLException: ERROR: column "a"
is of type bit but expression is of type boolean
 
How can I set bit string field in PreparedStatement?
 
 
Thanks.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



view thread (2+ messages)  latest in thread

Message-ID: <20050414154508.66799.qmail@web50407.mail.yahoo.com>
Permalink:  ../20050414154508.66799.qmail@web50407.mail.yahoo.com/
Also on:    postgresql.org/message-id/20050414154508.66799.qmail@web50407.mail.yahoo.com

 · 

reply

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: bst_co@yahoo.com
  Subject: Re: Bit string type in PreparedStatement
  In-Reply-To: <20050414154508.66799.qmail@web50407.mail.yahoo.com>
  References: <20050414154508.66799.qmail@web50407.mail.yahoo.com>

* 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